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 ruleP2stack specificStack: typescript
typescriptglobalstypesoptional
If a global may be absent, type it as optional
When window globals might not exist, reflect that in the type definitions (optional) rather than asserting and guarding ad hoc.
PR: hegnar-web · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetypescript
| 1 | interface Window { Header: { user: User }; } |
| 2 | if (window.Header && window.Header.user) { /* ... */ } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | interface Window { Header?: { user?: User }; } |
Explanation (EN)
Objašnjenje (HR)