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 ruleP1stack specificStack: typescript
typescripttypesdrymaintainability
Share one source-of-truth type instead of duplicating type definitions
Derive related types from a single shared type (via Exclude/Extract) so a change in one place forces TypeScript to flag every dependent spot.
PR: hegnar-web · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetypescript
| 1 | // in component A |
| 2 | type Source = 'all' | 'a' | 'b' | 'c'; |
| 3 | // in component B, duplicated and easy to drift |
| 4 | type ItemType = 'a' | 'b' | 'c'; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | type Source = 'all' | 'a' | 'b' | 'c'; |
| 2 | type ItemType = Exclude<Source, 'all'>; |
Explanation (EN)
Objašnjenje (HR)