no-unnecessary-type-constraint
JavaScript / TypeScriptsuspiciousno fixdefault: offjs/typescript-eslint-recommendedjs/biome-recommended
What it does
Section titled “What it does”Reports a type parameter constrained to any or unknown (<T extends unknown>, also with a default).
Why it matters
Section titled “Why it matters”Every type parameter already accepts any type, so extends unknown and extends any restrict nothing and add noise (extends any also lets a reader think the check is turned off by choice).
To fix, remove the constraint.
Example
Section titled “Example”function f<T extends unknown>(x: T) {}function g<T extends string>(x: T) {}...Configuration
Section titled “Configuration”js: lint: rules: no-unnecessary-type-constraint: warn # off (default), warn, errorEnabled by the presets: js/typescript-eslint-recommended, js/biome-recommended.
Suppress one line with sudsy-disable-next-line no-unnecessary-type-constraint in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| typescript-eslint | no-unnecessary-type-constraint |
full |