Skip to main content

Enforce valid definition of new and constructor (no-misused-new)

Warns on apparent attempts to define constructors for interfaces or new for classes.

Rule Details

Examples of incorrect code for this rule.

class C {
new(): C;
}

interface I {
new (): I;
constructor(): void;
}

Examples of correct code for this rule.

class C {
constructor() {}
}
interface I {
new (): C;
}

Options

{
"@typescript-eslint/no-misused-new": "error"
}

Compatibility

Attributes

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