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
typescripttype-guardsfilter
Narrow a filter with an intersection type instead of restating the whole shape
In a type predicate, intersect the original type with the narrowed field so you don't have to re-list every property.
PR: hegnar-bellsheep-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codets
| 1 | data.filter((t): t is { fullname: string; id: number; name?: string } => t.fullname !== null) |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | data.filter((t): t is Omit<Ticker, 'fullname'> & { fullname: string } => t.fullname !== null) |
Explanation (EN)
Objašnjenje (HR)