avoid-unnecessary-type-params
Installation
SKILL.md
Avoid Unnecessary Type Parameters
Overview
The "Golden Rule of Generics" states that type parameters should appear twice or more in a function signature. If a type parameter only appears once, it's not relating anything and is likely unnecessary. Unnecessary type parameters create a false sense of type safety and can make inference less successful.
This skill helps you identify and eliminate superfluous type parameters, resulting in cleaner, more maintainable code that TypeScript can infer more effectively.
When to Use This Skill
- Writing generic functions or types
- Reviewing type signatures for clarity
- A type parameter appears only once (besides its declaration)
- Tempted to add generics for "flexibility"
- Debugging poor type inference
The Iron Rule
Type parameters must appear twice or more to establish a relationship. If a type parameter only appears once, strongly reconsider if you need it.