In my current scenario, I have a class that implements an interface. Surprisingly, the TypeScript compiler does not throw an error if the class fails to include the required method specified by the interface; instead, it executes with an error.
Is there a way to ensure that the compiler throws an error when a required method is missing?
interface PersonInterface {
name: string;
age: number;
}
class Person implements PersonInterface {
name: string = 'Mary';
foo: any = 'abc';
}
alert(new Person().name)
You can view and test the code here at the playground here
View my code on CodeSandbox: here