capypad
0 day streak
typescript / beginner
Snippet

Interface Inheritance

Interfaces can extend other interfaces, allowing you to copy members from one into another and build complex types from simpler ones.

snippet.ts
typescript
1
2
interface Animal { name: string; }
interface Dog extends Animal { breed: string; }
Breakdown
1
extends Animal
The Dog interface inherits the 'name' property from the Animal interface.
2
breed: string
Adds a new property specific to the Dog interface.