TS17009

TS17009: ‘super’ must be called before accessing ‘this’ in the constructor of a derived class.

Bad Code ❌

1
2
3
4
5
6
7
8
9
10
11
12
abstract class Animal {
abstract name: string;
}

class Dog extends Animal {
public name;

constructor(name: string) {
this.name = name;
super();
}
}

Fixed Code ✔️

1
2
3
4
5
6
7
8
9
10
11
12
abstract class Animal {
abstract name: string;
}

class Dog extends Animal {
public name;

constructor(name: string) {
super();
this.name = name;
}
}