Skip to content

constructorSupers

Reports constructors of derived classes that do not call super(), and constructors of non-derived classes that call super().

✅ This rule is included in the ts javascript presets.

Constructors of derived classes (classes that extend another class) must call super() before accessing this or returning. Constructors of non-derived classes must not call super(). Violating either requirement causes a runtime error.

This rule reports code that appears to violate either requirement.

class Child extends Parent {
constructor() {
this.value = 1;
}
}
class Child extends Parent {
constructor(name: string) {
this.name = name;
}
}
class Example {
constructor() {
super();
}
}

This rule is not configurable.

TypeScript’s compiler enforces this check, so this rule is redundant when using TypeScript with type checking enabled. Disable this rule if you are using TypeScript’s type checker and want to reduce redundant linting.

Made with ❤️‍🔥 around the world by the Flint team and contributors.