Extending Interfaces

What

Extending allows an interface to inherit all the properties and methods of another interface.

How

You use the extends keyword to create a child interface based on a parent interface:

interface Character {
  name: string;
  level: number;
}

interface Wizard extends Character {
  spellbook: string[];
  mana: number;
}

Why

Using extends is generally superior to using type intersections (&) for object extension. Interfaces create a flat object structure that makes property conflicts easier to detect and resolve. Furthermore, TypeScript can cache interface relationships, leading to faster compilation times and clearer error messages in large projects.

Summary

Use interface extends to build clean, performant type hierarchies for your object models.