TypeScript type vs interface: Key differences and when to use each
TypeScript developers can define object shapes with either a type alias or an interface, and the two look nearly identical at first glance. Both reject unexpected extra properties through excess property checks, so that behavior does not separate them. Interfaces can extend type aliases and vice versa, though an interface cannot extend a union type. Type aliases offer more flexibility by representing unions, intersections, primitives, tuples, and conditional types. Interfaces, in contrast, support declaration merging, which suits extending third-party declarations and public APIs, but type aliases do not allow duplicate declarations.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in