Type vs Interface
For describing the shape of an object, type and interface are close to interchangeable. They differ in what else each can do: interfaces merge and are built for extension, while type aliases can name unions, tuples, and computed types.
Detailed Explanation
This is the most common style argument in a TypeScript codebase, and most of the heat comes from people comparing the wrong thing. Write out an object shape both ways and the compiler treats the results almost identically. Assignability in TypeScript is structural, so nothing checks which keyword produced a type — only what members it has.
The real question is what each keyword can express.
A type alias is a name for any type. That includes types an interface cannot describe at all: unions, tuples, function types you want to compose, keyof results, mapped types, conditional types, and template literal types. If a type is computed from another type, it needs an alias.
An interface describes object-like things only: property bags, call signatures, construct signatures, index signatures. In exchange it gets two abilities aliases do not have. It merges, so two interfaces with the same name in the same scope combine into one — the mechanism that lets you add a field to a third-party type. And it is designed for extends chains, which the compiler caches as named relationships.
| Capability | interface | type |
|---|---|---|
| Object shapes | yes | yes |
implements on a class | yes | yes, if the alias is an object type |
| Unions, tuples, mapped, conditional | no | yes |
| Declaration merging | yes | no, duplicate name is an error |
| Extending | extends | & intersection |
Two behavioral differences are worth knowing before you pick.
Conflicts are reported differently. If an interface extends a parent and re-declares a property with an incompatible type, that is an error on the spot. An intersection does not error — it produces a property whose type is the impossible overlap, often never, and the failure surfaces later at some unrelated assignment.
Errors read differently. An interface usually keeps its name in diagnostics. A long intersection of aliases tends to get expanded into its members, which is how you end up with a forty-line error message about an object literal.
The practical recommendation used by the TypeScript team and most large codebases: reach for interface when you are declaring an object shape, especially a public or extensible one, and reach for type for everything else. Neither costs anything at runtime — both are erased entirely. The only real cost is inconsistency, so if a codebase already picked one convention, follow it rather than relitigating it in review.
Code Examples
1. Same shape, both keywords. The class does not care which you used.
// 1. Same shape, both keywords. The class does not care which you used.
interface PaymentIntent {
id: string;
amountCents: number;
}
type Refund = {
id: string;
amountCents: number;
};
// A class can implement either, because both are object types.
class LedgerEntry implements PaymentIntent {
constructor(public id: string, public amountCents: number) {}
}
// And they are mutually assignable, because assignability is structural.
const a: PaymentIntent = { id: "pi_1", amountCents: 500 };
const b: Refund = a; // fine2. Things only a type alias can name.
// 2. Things only a type alias can name.
type Currency = "usd" | "eur" | "inr"; // union
type Pair = [start: Date, end: Date]; // tuple
type Handler = (event: MouseEvent) => void; // function type
type Flags = Record<Currency, boolean>; // computed from another type
type Key = keyof PaymentIntent; // "id" | "amountCents"
interface Bad extends Currency {}
// Error: An interface can only extend an object type or intersection of object types with statically known members.3. Merging vs. duplicate names, and the silent intersection conflict.
// 3. Merging vs. duplicate names, and the silent intersection conflict.
interface Config {
region: string;
}
interface Config {
retries: number;
}
const cfg: Config = { region: "ap-south-1", retries: 3 }; // both members required
type Settings = { region: string };
// type Settings = { retries: number };
// Error: Duplicate identifier 'Settings'.
interface HasId {
id: string;
}
interface Conflict extends HasId {
id: number;
}
// Error: Interface 'Conflict' incorrectly extends interface 'HasId'.
type Quiet = HasId & { id: number }; // no error here...
declare const q: Quiet;
q.id; // ...but the type is 'never', so every use of it fails laterCommon Gotchas
For a plain object shape, the choice is cosmetic
the compiler will not treat your code differently. Spend the review comment on naming and member types instead, and keep the codebase consistent.
Interface merging is silent and easy to do by accident
a second `interface User` anywhere in the same scope adds members rather than raising a duplicate-name error. Two developers can each define half of a type without either noticing.
Intersections hide conflicts instead of reporting them
`A & B` with the same key at incompatible types yields an uninhabitable property, usually `never`. You get an error at the assignment site, far from the declaration that caused it.
Deep intersection chains cost compile time and readability
each intersection is re-checked structurally, and error messages expand into their members. Named `extends` chains stay named and are cheaper for the compiler to compare.