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

Interface Extension vs Intersection Types

How interface extension differs from type alias intersections and when conflicts occur.

Interface Extension vs Intersection Types

What you'll learn: How interface extension differs from type alias intersections and when conflicts occur.

Two Ways to Combine Types

Both interface extension and intersection types let you combine multiple types into one, but they behave differently when properties conflict.

Interface Extension Recap

When you extend an interface, you're creating a new interface that inherits all properties from the parent:

interface User {
  name: string;
}

interface AdminUser extends User {
  permissions: string[];
}

Type Alias Intersection

With type aliases, you use the & operator to create an intersection:

type User = {
  name: string;
};

type AdminUser = User & {
  permissions: string[];
};

The Critical Difference: Conflicts

Here's where they diverge. When the same property appears in both types with incompatible types, interfaces produce a compile-time error, while intersections attempt to merge them (often creating never):

interface A {
  value: string;
}

// Error: Interface 'B' incorrectly extends 'A'
interface B extends A {
  value: number; // Conflict detected immediately
}
type A = {
  value: string;
};

type B = A & {
  value: number; // No immediate error
};

// But value becomes string & number = never (unusable)

Analogy: Interface extension is like a strict blueprint inspector who rejects incompatible plans immediately. Intersection types are like overlaying two transparencies—when they conflict, you get an impossible result.

Key Takeaway: Use interface extension when you want TypeScript to catch incompatible property redeclarations early. Use intersections when you're intentionally merging types that shouldn't overlap.