TypeScript · Types that pay for themselves
What is the difference between interfaces and type aliases?
Short answer
Both describe object shapes. Interfaces can be reopened through declaration merging and are natural for extendable object contracts; type aliases can also express unions, tuples, mapped and conditional types.
For a plain object shape, an interface and a type alias are largely interchangeable. The difference appears at the edges: interfaces support declaration merging and can be extended by other interfaces or implemented by classes, while type aliases can name any type expression, including unions and conditional types.
interface User {
id: number;
name: string;
}
type UserId = number | string;
interface Admin extends User {
role: "admin";
}
type AdminUser = User & { role: "admin" };The practical differences
- An interface can be declared more than once and the declarations merge
- A type alias cannot be reopened, so its shape is fixed at declaration
- Interfaces can extend other interfaces and be implemented by classes
- Type aliases can represent unions, tuples, primitives and conditional types
- Both are structural, so compatibility is based on shape rather than name
Declaration merging is useful for augmenting library types, but it can also surprise a reader because a shape is assembled from several files. Type aliases make the full definition visible in one place. Neither choice affects runtime behavior.
Follow-ups you should expect
Interviewers use these to check whether the first answer was understanding or memorisation.
- 1Can an interface extend a type alias?
- 2When is declaration merging useful?
- 3Can a type alias be implemented by a class?
- 4Which one should be the default in a codebase?
Say it in the interview
Interfaces and type aliases both describe object shapes, and for simple objects they are interchangeable. I use interfaces when I want an extendable contract or declaration merging, such as augmenting a library type. I use type aliases when I need unions, tuples, mapped types or conditional types, which interfaces cannot express. In a codebase I pick one default and stay consistent.
Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.
Related questions
Reading is step one
Now say it out loud.
Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live TypeScript mock interview and get scored feedback on depth, clarity and confidence.