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
class Child
Child
extends
class Parent
Parent
{
constructor() {
this.
any
value
= 1;
}
}
class
class Child
Child
extends
class Parent
Parent
{
constructor(
name: string
name
: string) {
this.
any
name
=
name: string
name
;
}
}
class
class Example
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.