TypeScript
Interface Inheritance
Interface inheritance and implementation.
By EZ4Code Team
interfaceinheritance
Code
interface Animal {
name: string;
move(): void;
}
interface Dog extends Animal {
bark(): void;
}
interface Bird extends Animal {
fly(): void;
}
class Husky implements Dog {
constructor(public name: string) {}
move() { console.log("running"); }
bark() { console.log("woof"); }
}
// Multiple inheritance
interface Hybrid extends Dog, Bird {}Explanation
Interfaces support multiple inheritance; classes implement interfaces via implements.