Interface vs Type
Question
What is the difference between interface and type alias?
Hint
Interfaces support declaration merging; type aliases do not.
Explanation
Both can describe object shapes. Key differences: 1) Interfaces support declaration merging (multiple interface declarations with the same name combine). 2) Type aliases can describe unions, intersections, tuples, primitives — interfaces only describe object shapes. 3) Interfaces are generally preferred for extendable object types (classes implement them). 4) Type aliases are preferred for unions, tuples, and computed types. Use interface for objects that might be extended, type for unions and utility types.
Related Resources
Related Lessons
- Interfaces
Learn interfaces.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.