no-misused-new
Enforces valid definition of new
and constructor
.
Warns on apparent attempts to define constructors for interfaces or new
for classes.
Attributes
- Included in configs
- ✅ Recommended
- 🔒 Strict
- Fixable
- 🔧 Automated Fixer
- 🛠 Suggestion Fixer
- 💭 Requires type information
Rule Details
Examples of code for this rule:
- ❌ Incorrect
- ✅ Correct
class C {
new(): C;
}
interface I {
new (): I;
constructor(): void;
}
class C {
constructor() {}
}
interface I {
new (): C;
}
Options
// .eslintrc.json
{
"rules": {
"@typescript-eslint/no-misused-new": "error"
}
}
This rule is not configurable.
Related To
- TSLint: no-misused-new