JS.TS.NO.MISUSED.NEW

Enforce valid definition of 'new' and 'constructor'

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

Rule Details

Examples of code for this rule:

<!--tabs-->

Incorrect

Copy
class C {
  new(): C;
}

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

Correct

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

Options

Copy
// .eslintrc.json
{
  "rules": {
    "@typescript-eslint/no-misused-new": "error"
  }
}

This rule is not configurable.

The content on this page is adapted from the ESLint User Guide. Copyright © OpenJS Foundation and other contributors, www.openjsf.org. All rights reserved. https://eslint.org/docs/rules/