TypeScript's type vs. interface: The Real Difference Is Inheritance vs. Type Algebra
Choosing between `type` and `interface` shapes how a codebase handles extension, augmentation of third-party types, and non-object type expressions. Picking the wrong one locks you out of declaration merging or forces awkward workarounds for union and tuple types.
Both `type` and `interface` describe object shapes, but `interface` uses `extends` for nominal-style inheritance while `type` uses `&` for structural intersection—a type-algebra operation that merges property sets without declaring subtype relationships. `interface` alone supports declaration merging, letting you augment third-party types without modifying source code. `type` alone can express union types, tuples, and literal types that `interface` cannot. For function types, `type`'s arrow-style syntax is more concise than `interface`'s call-signature approach. In React codebases, `interface` dominates component Props because its `extends` semantics align with the contract model between parent and child components, and its declaration merging allows seamless augmentation of library types. The practical rule: reach for `interface` when defining object contracts like component Props, and `type` for utility types, unions, and type-level transformations.
The `extends` vs. `&` distinction is not just syntactic sugar—it encodes two different type-system philosophies: nominal typing inherited from Java-style OOP versus structural type algebra. This choice surfaces in code-review discussions about whether a type should express an is-a relationship or a has-these-properties merge.
Declaration merging is the feature that makes `interface` strategically important in library and platform code, but it is also a footgun: accidental merges can silently widen types in ways that are hard to debug.
The React community's near-universal preference for `interface` Props is partly convention and partly a real constraint—declaration merging lets teams extend library component types without waiting on upstream PRs, which matters at scale.