TypeScript Fundamentals

Interfaces vs Type Aliases

Interfaces and type aliases both name shapes. Interfaces are object-focused and can merge; type aliases can name any type expression, including unions, intersections, tuples, primitives, and mapped/conditional types.
  • Both work for ordinary object shapes
  • Interfaces support declaration merging
  • Type aliases handle unions and advanced expressions
  • Public extension is a design signal
  • Avoid holy wars
Use each where it fits
interface User {
  id: string
  name: string
}

type LoadState<T> =
  | { kind: "loading" }
  | { kind: "success"; data: T }
  | { kind: "error"; error: Error }
Interfaces shine for object contracts; aliases are required for unions.
Choosing interface or type
NeedUsually choose
Plain object modelEither
Public augmentable APIinterface
Union typetype
Tupletype
Mapped/conditional typetype
Declaration merginginterface
Sources
  • The TypeScript HandbookObject Types
  • Effective TypeScript, 2nd EditionType design
  • TypeScript ReferenceDeclaration merging