Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
fullstack ruleP1universalStack: typescript
typescriptapitypescontracts
Model types after the documented API schema
Derive request/response types from the API contract (Swagger/OpenAPI) instead of inventing fields, and drop fields the API does not return.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetypescript
| 1 | interface User { |
| 2 | parentPostId: number; // not in the API schema |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | // matches BaseUser in the API docs |
| 2 | interface User { |
| 3 | id: number; |
| 4 | username: string; |
| 5 | } |
Explanation (EN)
Objašnjenje (HR)