constructorSupers
Reports constructors of derived classes that do not call
super(), and constructors of non-derived classes that callsuper().
✅ 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.
Examples
Section titled “Examples”class Child extends Parent { constructor() { this.value = 1; }}class Child extends Parent { constructor(name: string) { this.name = name; }}class Example { constructor() { super(); }}class Child extends Parent { constructor() { super(); this.value = 1; }}class Child extends Parent { constructor(name: string) { super(name); this.name = name; }}class Example { constructor() { this.value = 1; }}class Child extends Parent { value = 1;}Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”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.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- Biome:
noInvalidConstructorSuper - Deno:
constructor-super - ESLint:
constructor-super
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.