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
typescriptgenericssimplicityyagni
Don't reach for generics when each concrete case maps differently
A generic type parameter only pays off when implementations are identical except for T. If each variant hardcodes its own mapping, a plain shared interface with a differing field is simpler.
PR: hegnar-ws · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | export interface ILatestNewsTeaser<T extends ArticleSource> { |
| 2 | source: T; |
| 3 | // ... all other fields identical regardless of T |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | export interface ILatestNewsTeaser { |
| 2 | source: ArticleSource; // value differs, shape does not |
| 3 | // ... shared fields |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)