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).
backend ruleP2universalStack: TypeScript
typescriptunion-typestype-safety
Type fixed method/identifier sets as a union, not string
For parameters that only accept a known set of values (e.g. HTTP method names), use a string-literal union type instead of plain string to catch typos.
PR: hegnar-forum-web · org-mining-3rd-2026-06Created: Jun 18, 2026
Bad example
Old codets
| 1 | private static handleUnsuccessfulResponse = (method: string, response: Response) => { /* ... */ }; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | type HttpMethod = 'GET' | 'POST' | 'PATCH' | 'DELETE'; |
| 2 | private static handleUnsuccessfulResponse = (method: HttpMethod, response: Response) => { /* ... */ }; |
Explanation (EN)
Objašnjenje (HR)