Interfaces vs Type Aliases

Both interface and type can describe object shapes and are often interchangeable for ordinary object contracts. Interfaces support declaration merging and can be extended with extends. Type aliases can name unions, intersections, primitives, tuples, and mapped or conditional types. Pick the form that communicates intent and fits the library's extension model.

Avoid arguing that one is universally better. Public library APIs sometimes use interfaces for extendable object contracts; aliases are essential for unions and type-level transformations. Keep naming consistent within a codebase.

Interface and type alias
interface Identified {
  id: string;
}

interface Customer extends Identified {
  email: string;
}

type ApiStatus = "idle" | "loading" | "done";
💡 Customer extends an object interface. ApiStatus is a union, which is naturally represented by a type alias.
Key Takeaways
  • Both can describe object shapes.
  • Interfaces can merge declarations; aliases can represent unions and other type expressions.
  • Consistency and the intended extension model matter more than dogma.
Knowledge Check

Which construct is required to name a union such as `"open" | "closed"`?