TS2335

error TS2335: ‘super’ can only be referenced in a derived class.

Bad Code ❌

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

class Cat {
constructor() {
super();
}

makeNoise(): string {
return 'Meow!';
}
}

Fixed Code ✔️

Your derived class has to “extend” the base class:

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

class Cat extends Animal {
constructor() {
super();
}

makeNoise(): string {
return 'Meow!';
}
}