Docs
/
TypeScript
Chapter 8

08 — Type Aliases vs Interfaces

Core Concepts

  • Type aliasestype Name = ... can represent any type
  • Interfacesinterface Name { } only for object shapes
  • Declaration merging — only interfaces can be merged
  • Extends vs Intersection — interfaces extends, types use &
  • Computed/mapped types — only possible with type aliases
  • Performance — interfaces are slightly faster for the compiler to check

Quick Decision Guide

NeedUse
Object shapeEither (interface slightly preferred)
Union typeType alias
Mapped typeType alias
Conditional typeType alias
Declaration mergingInterface
Class implementsEither
Primitive aliasType alias
TupleType alias
Function typeEither (type alias is cleaner)