Let's now see how you can use interfaces in TypeScript.
TypeScript interfaces
Defining contracts
In terms of OO design, we have seen that interfaces play a big role as they allow us to define and enforce contracts in a code base, whether for internal or external (that is, client) code.
First of all, of course, TypeScript interfaces allow you to define such contracts. Here's a simple example:
interface MusicPlayer { play(): void; pause(): void; stop(): void; rewind(seconds: number): void; fastForward(seconds: number): void; }
As you can see, we just need to use the interface keyword and list the method signatures. Any element realizing (that is, implementing) this interface will have to...