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

Type Aliases Cannot Merge

Why type aliases don't support declaration merging and how this limits their extensibility.

Type Aliases Cannot Merge

What you'll learn: Why type aliases behave differently from interfaces when it comes to declaration merging, and what that means for your code's extensibility.


The Core Difference

In the previous lesson, you saw how interfaces support declaration merging—the ability to declare the same interface multiple times and have TypeScript automatically combine all the properties. Type aliases don't work this way.

When you use a type alias, you get exactly one declaration. If you try to declare the same type alias twice, TypeScript will throw an error immediately.

type User = {
  name: string;
};

// ❌ Error: Duplicate identifier 'User'
type User = {
  age: number;
};

This is a hard boundary. Unlike interfaces, which merge their properties together, type aliases are final the moment you declare them.

Why This Limitation Exists

Type aliases are meant to be simple name replacements. Think of them like nicknames: once you decide "Bob" refers to Robert, you can't later say "Bob" also refers to Barbara. The name points to one thing.

Interfaces, by contrast, are designed for extensibility and augmentation—they're meant to grow and adapt, especially when working with third-party libraries or modular code.

Practical Impact

This means you cannot:

  • Split a type alias across multiple files for organization
  • Augment third-party library types that use type aliases
  • Gradually add properties to a type in different parts of your codebase

You must define the complete type in one place, or use intersection types to combine them explicitly.

Key Takeaway: Type aliases cannot merge—each type alias name can only be declared once, making them less flexible than interfaces for scenarios requiring extensibility or augmentation.