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
typescriptinferenceredundancy
Omit type annotations the compiler already infers
Don't restate a function's return type or a variable type when TypeScript infers it correctly from arguments or initializer.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetypescript
| 1 | const getName = (user: User): string => user.name; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const getName = (user: User) => user.name; // return type inferred as string |
Explanation (EN)
Objašnjenje (HR)