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).
frontend ruleP1stack specificStack: typescript
typescriptpropsnull-safetystrict-null-checks
Make prop types match the values actually passed
If null can be passed, the prop type must allow null (or guard the call); mismatches would surface as errors under strict null checks.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetypescript
| 1 | interface Props { id: number } |
| 2 | <Cmp id={selectedId /* number | null */} /> |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | interface Props { id: number | null } |
| 2 | // or: don't call when id is null |
Explanation (EN)
Objašnjenje (HR)