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 ruleP2universalStack: TypeScript
typescripttypesprops
Type props with a finite union when the values are known
If a prop only ever takes a few known values, type it as a union of literals; fall back to `string` only when the value set is genuinely open.
PR: hegnar-forum-web · org-mining-3rd-2026-06Created: Jun 18, 2026
Bad example
Old codets
| 1 | interface AdProps { |
| 2 | pos?: string; // pos is one of a known set of positions |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | type AdPosition = 'top' | 'left' | 'right' | 'bottom'; |
| 2 | interface AdProps { |
| 3 | pos?: AdPosition; |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)