Key differences
| Feature | interface |
type |
|---|---|---|
| Declaration merging | ||
| Extends other types | extends keyword |
& intersection |
| Primitive aliases | ||
| Computed properties | ||
| Union types |
Use interface for:
- Object shapes — especially when working with classes
- Public API types in libraries (supports declaration merging)
- OOP patterns
Use type for:
- Unions:
type Status = 'active' | 'inactive' | 'pending' - Mapped types:
type Partial<T> = { [K in keyof T]?: T[K] } - Utility compositions:
type AdminUser = User & { role: 'admin' } - Primitives:
type ID = string | number
Deloitte team convention: use interface for component props and data models, type for unions and utility types.