TS2391
error TS2391: Function implementation is missing or not immediately following the declaration.
Broken Code ❌
1 |
|
Fixed Code ✔️
An abstract class is different from an interface. You have to use the abstract
modifier if you want to define a contract in an abstract class. If there is no abstract
modifier you will have to provide a implementation.
Solution 1:
To solve the problem, we can mark makeNoise
with the abstract
keyword. That will enforce derived classes to implement this method on their own:
1 |
|
Solution 2:
Another solution is to provide a base implementation for makeNoise
:
1 |
|