Skip to main content

Enforces that type arguments will not be used if not required (no-unnecessary-type-arguments)

Warns if an explicitly specified type argument is the default for that type parameter.

Rule Details

Type parameters in TypeScript may specify a default value. For example:

function f<T = number>() {}

It is redundant to provide an explicit type parameter equal to that default.

Examples of code for this rule:

function f<T = number>() {}

function g<T = number, U = string>() {}
g<string, string>();

class C<T = number> {}
function h(c: C<number>) {}
new C<number>();
class D extends C<number> {}

interface I<T = number> {}
class Impl implements I<number> {}


  • โœ… Recommended
  • ๐Ÿ”ง Fixable
  • ๐Ÿ’ญ Requires type information