What You'll Learn
You'll understand the key difference between merging types with intersections (&) and extending interfaces with extends, and when to choose each approach.
The Core Difference
When you need to combine types in TypeScript, you have two main tools: intersection types (&) and interface extension (extends). While they often produce similar results, they work in fundamentally different ways.
Intersections perform structural merging. They take two types and combine all their properties into a single type. Think of it like mixing paint colors — you get a new blend containing everything from both sources.
Interface extension creates a hierarchical relationship. The extending interface inherits from the base interface, establishing a parent-child connection. It's more like a family tree — the child carries the parent's traits but remains a distinct entity.
When It Matters
interface Base {
name: string;
}
// Extension: Child "is a" Base
interface Child extends Base {
age: number;
}
// Intersection: merging structures
type Person = Base & { age: number };
Both Child and Person look identical in practice — they both have name and age. But extension declares an explicit relationship, while intersection just combines shapes.
Extensions also give you better error messages when properties conflict, because TypeScript recognizes the hierarchical intent. Intersections, by contrast, merge mechanically and can create strange results with conflicting types.
Key Takeaway: Use extends when you want to express a clear "is-a" relationship between interfaces; use & when you're structurally combining types (especially unions or complex type aliases).