Back
TypeScriptEasyNew

What is the difference between interface and type?

Consider declaration merging and unions.

Ideal Answer

Both describe object shapes, but differ in capabilities:

Interface

  • Supports declaration merging.
  • Better for public API contracts and extending object shapes.

Type

  • Supports unions, intersections, tuples, and mapped/conditional types.
  • Cannot be reopened/merged after creation.

For simple object shapes either works. Prefer interface for extendable object contracts; prefer type for unions and advanced type logic.