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
typesnulldomain-modeling
Model deleted/absent entity fields as nullable and check all of them
When a field signals a deleted/absent entity (e.g. nickname null = deleted user), make it nullable in the type, and re-check related fields (id) for the same null semantics rather than assuming.
PR: hegnar-forum-web · org-mining-3rd-2026-06Created: Jun 18, 2026
Bad example
Old codets
| 1 | type User = { id: number; nickname: string }; |
| 2 | const isUserDeleted = false; // hardcoded |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | type User = { id: number | null; nickname: string | null }; // null when deleted |
| 2 | const isUserDeleted = !nickname; |
Explanation (EN)
Objašnjenje (HR)