Why is this an issue?
The TypeScript programming language supports generics, a programming construct for creating reusable components, that is, components that
can work over various types rather than a single one. Sometimes, we need to limit this genericity to a specific set of types, typically when we know
these types share common capabilities, e.g., a length
property. To this end, the language provides the extends
clause to
describe type constraints on type parameters, whether for classes, interfaces, type aliases, or functions.
By default, a type parameter extends the any
type. It is therefore redundant to explicitly extend from any
and should be
removed accordingly.
How to fix it
Fixing such an issue involves removing the redundant type constraint to any
.
Code examples
Noncompliant code example
class C<T extends any> {
// ...
}
Compliant solution
class C<T> {
// ...
}
Resources
Documentation