Skip to content

thisBeforeSuper

Reports using this or super before calling super() in derived class constructors.

✅ This rule is included in the ts untyped presets.

In JavaScript, when a class extends another class, the constructor must call super() before accessing this or super.property. Attempting to access this or super properties before calling super() throws a ReferenceError.

class Child extends Parent {
constructor() {
this.value = 0;
super();
}
}
class Child extends Parent {
constructor() {
super.initialize();
super();
}
}

This rule is not configurable.

If your code is transpiled in a way that does not match modern ECMAScript semantics, this rule may not be for you.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.