Course contentsShow
← TypeScript
Lesson 376 of 1,7968. Interfaces vs Type AliasesFree lesson

Extends vs Intersection: Subtle Semantic Differences

Interface extends enforces compatibility at declaration time; type intersections defer conflict resolution to usage sites.

Extends vs Intersection: Subtle Semantic Differences

You'll learn: How interface extends checks compatibility immediately, while type intersections (&) defer error detection to where you actually use the type.

The Core Difference

When you use extends with interfaces, TypeScript verifies compatibility at declaration time—right when you write the extension. If there's a conflict between property types, you get an error immediately.

With type intersections using &, TypeScript accepts the definition without complaint. It merges the types together, and any conflicts only surface when you try to use the resulting type.

Declaration-Time vs Usage-Time Errors

Think of extends like a strict contract review that happens during signing—conflicts are caught before the deal is done. Intersections (&) are more like "we'll figure it out later"—the type system accepts contradictory constraints and only complains when you try to create a value.

interface Base {
  value: string;
}

// Error immediately: number is not assignable to string
interface Extended extends Base {
  value: number;
}

// No error yet!
type Intersection = Base & { value: number };

// Error only when you try to use it:
const obj: Intersection = {
  value: ??? // No value can be both string AND number
};

The extends version saves you time by catching the mistake early. The intersection version creates an impossible-to-satisfy type (never for that property).

Key Takeaway: Use extends when you want early error detection for incompatible properties; intersections defer conflict resolution, which can create confusing types that fail only at usage sites.