Both define object shapes, but interfaces can be extended/merged while types support unions, intersections, and mapped types.
In TypeScript, both type aliases and interfaces can be used to define object shapes, but they have different capabilities and use cases.
Interfaces are primarily designed for defining object shapes and can be extended using the extends keyword. A key feature of interfaces is declaration merging—if you declare an interface with the same name twice, TypeScript will merge them into a single interface. This is useful for augmenting existing types from libraries.
Type aliases are more versatile. They can represent not just objects but also primitives, unions, tuples, and other types. Types use intersection (&) to combine types rather than extends. You can create union types (type Status = 'pending' | 'completed'), mapped types, and conditional types with type aliases.
In practice: use interfaces when defining object shapes that might be extended or when working with classes (interfaces can be implemented). Use types when you need union types, mapped types, or other advanced type features. Many teams have style guides that prefer one over the other for consistency—both work well for most use cases.
Both define object shapes, but interfaces can be extended/merged while types support unions, intersections, and mapped types.
Join our network of elite AI-native engineers.