Interfaces vs. Type Aliases
Prerequisites: Interfaces, Type aliases
Both describe object shapes, and are interchangeable for most simple cases — the practical differences that matter:
- Interfaces can be "reopened" — declaring
interface User { }twice merges the two declarations.typecannot be redeclared. - Interfaces can
extendsanother interface directly;typeuses&(intersection) to combine shapes instead. typecan alias anything — unions, tuples, primitives — not just object shapes.
A common convention: prefer interface for object shapes (especially
ones a library's users might extend), and type for unions, tuples,
or anything that isn't a plain object shape.