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
typescripttypesthird-partysafety
Provide explicit typings for third-party globals instead of `any`
When a vendor SDK lacks types, write a best-effort interface for the parts you use; even imperfect typings beat `any`.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | (window as any)._googCsa('ads', pageOptions, blockOptions); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | interface GoogCsa { (kind: string, page: IPageOptions, block: IBlockOptions): void; } |
| 2 | (window as Window & { _googCsa?: GoogCsa })._googCsa?.('ads', pageOptions, blockOptions); |
Explanation (EN)
Objašnjenje (HR)