Interface Extension and Merging
Extend interfaces and understand declaration merging.
Welcome
Interfaces can extend other interfaces to build on existing shapes, and TypeScript merges multiple declarations of the same interface automatically.
Extending an Interface
Use the `extends` keyword to create a new interface that includes all properties from the parent.
interface Animal { name: string; }
interface Dog extends Animal {
breed: string;
}
const rex: Dog = { name: 'Rex', breed: 'Labrador' };All lessons in this course
- Defining Object Shapes with Interfaces
- Type Aliases for Complex Types
- Interface Extension and Merging
- Interface vs Type: When to Use Each