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 ruleP2universalStack: TypeScript
typescripttypesorganizationclean-code
Put values used purely as types in the types layer
A constant or object that exists only to derive a type (e.g. via typeof for an aspectRatio) is effectively a type and should be declared/treated as one rather than mixed into runtime utility code.
PR: hegnar-forum-web · org-mining-3rd-2026-06Created: Jun 18, 2026
Bad example
Old codets
| 1 | // in a runtime util file, only ever used to type aspectRatio |
| 2 | export const aspectRatios = { square: 1, wide: 1.78 }; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | // expressed as a type since it's only used for typing |
| 2 | export type AspectRatio = 'square' | 'wide'; |
Explanation (EN)
Objašnjenje (HR)