Skip to content

no-unnecessary-type-constraint

Reports a type parameter constrained to any or unknown (<T extends unknown>, also with a default).

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.

Reported
function f<T extends unknown>(x: T) {}
function g<T extends string>(x: T) {}
...
js:
lint:
rules:
no-unnecessary-type-constraint: warn # off (default), warn, error

Enabled 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.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
typescript-eslint no-unnecessary-type-constraint full