Explain the difference between 'interface' and 'type' alias.

Updated May 4, 2026

Short answer

Interfaces are primarily for defining object shapes and support declaration merging, while types are more flexible for unions, intersections, and primitives.

Deep explanation

Interfaces are a powerful way to define contracts within your code or with external libraries. A unique feature of interfaces is 'declaration merging', where defining the same interface twice results in a single merged definition. Type aliases, created using the 'type' keyword, can represent primitives, unions, tuples, and intersections. Unlike interfaces, they cannot be changed once created (no merging).

Real-world example

Use interfaces for public API definitions so users can extend them. Use types for internal business logic where you need to combine existing types using Unions or Intersections.

Common mistakes

  • Using 'type' when you need to extend a library's global definitions (like adding a property to the Express Request object).

Follow-up questions

  • Can an interface extend a type?

More TypeScript interview questions

View all →