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 untyped 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
const Parent: any
Parent
{
constructor() {
Error ts(2377) ― Constructors for derived classes must contain a 'super' call.
this.
any
value
= 1;
Error ts(17009) ― 'super' must be called before accessing 'this' in the constructor of a derived class.
}
}
class
class Child
Child
extends
const Parent: any
Parent
{
constructor(
name: string
name
: string) {
Error ts(2377) ― Constructors for derived classes must contain a 'super' call.
this.
any
name
=
name: string
name
;
Error ts(17009) ― 'super' must be called before accessing 'this' in the constructor of a derived class.
}
}
class
class Example
Example
{
constructor() {
super();
Error ts(2335) ― 'super' can only be referenced in a derived class.
}
}

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.