no-useless-generics
Disallow type parameters that do not improve a declaration's type safety.
โ ๏ธ This rule requires type information to run.
Targeted pattern scopeโ
This rule targets TypeScript signatures that declare generic type parameters.
What this rule reportsโ
This rule reports generic parameters that do not provide meaningful type relationships.
Why this rule existsโ
Redundant generic parameters add cognitive overhead and can mislead readers into thinking polymorphism is required when it is not. This rule reports unnecessary generic type parameters.
โ Incorrectโ
function toUpper<T>(value: string): string {
return value.toUpperCase();
}
โ Correctโ
function identity<T>(value: T): T {
return value;
}
Behavior and migration notesโ
This rule forwards options to
@typescript-eslint/no-unnecessary-type-parameters.
- Lifecycle: Deprecated and frozen.
- Deprecated since:
v1.0.0 - Available until:
v2.0.0 - Use instead:
@typescript-eslint/no-unnecessary-type-parameters
Additional examplesโ
function parse<T extends string>(input: string): string {
return input.trim();
}
// โ reported: generic does not add a relation
function first<T>(items: readonly T[]): T | undefined {
return items[0];
}
// โ
valid: generic ties parameter and return type
ESLint flat config exampleโ
import etcMisc from "eslint-plugin-etc-misc";
export default [
{
plugins: { "etc-misc": etcMisc },
rules: {
"etc-misc/no-useless-generics": "error",
},
},
];
When not to use itโ
Disable this rule if your API surface intentionally keeps placeholder type parameters for generated declarations or staged migrations.
Package documentationโ
Rule catalog ID: R050
Further readingโ
Adoption resourcesโ
- Start at warning level in CI, then move to error after cleanup.
- Use focused codemods/autofix batches per package or directory.