TypeScriptInterview preparation
Intermediate·Concept·2 min read

Interface vs type: which should I use?

Practice this question

Definition:

Interfaces and type aliases both describe types that TypeScript checks before runtime. An interface is mainly used for object contracts, while a type alias can name object shapes, unions, tuples and other type expressions. Choosing between them is mostly about the shape being modeled and whether declaration merging is needed.

Key points:

  • Both can describe an object shape.

  • Interfaces can merge declarations; type aliases can also describe unions and other types.

  • Neither checks incoming API data at runtime.

  • An interface can extend another interface, and a type can combine object shapes through intersections.

  • TypeScript uses structural typing: matching members matter more than explicitly naming the same interface.

Interview point:

  • Both improve compile-time contracts, but neither creates a runtime validator or a JavaScript class.
Adapted from 01_JAVASCRIPT_TYPESCRIPT.md · “Interface vs type: which should I use?”. Code examples are study fragments. Difficulty and core labels are editorial estimates; version-specific behavior should be checked against your project.