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 ruleP1stack specificStack: typescript
typescriptgenericstype-safety
Use generic type parameters meaningfully, not as dead syntax
A declared generic <T> must actually constrain inputs/outputs; if a callback type ignores it, bind it to a concrete type or a named generic alias.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | interface IProps { |
| 2 | mappingFunction: <T>(props: T | Partial<T>, data: IData) => T | Partial<T>; |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | type TMappingFunction<T> = (props: T | Partial<T>, data: IData) => T | Partial<T>; |
| 2 | interface IProps { |
| 3 | mappingFunction: TMappingFunction<IArticle>; |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)