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 ruleP2universalStack: TypeScript
typescripttypesreadability
Keep null out of a named type alias; add it at the point of optionality
Define a type alias as the non-null shape and apply `| null` where the value is actually optional, instead of baking null into the alias itself.
PR: hegnar-ws · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | type TCategory = { name: string; id: number } | null; |
| 2 | interface Payload { category: TCategory; } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | type TCategory = { name: string; id: number }; |
| 2 | interface Payload { category: TCategory | null; } |
Explanation (EN)
Objašnjenje (HR)