Interface vs Type Alias
Use Interface When:
- Defining object shapes
- You need declaration merging
- Working with classes
- Building public APIs
Use Type When:
- Creating union or intersection types
- Defining tuple types
- Working with primitives
- Using mapped types
Comparison
| Feature | Interface | Type |
|---|---|---|
| Objects | ✅ | ✅ |
| Extends | ✅ | ✅ (via &) |
| Unions | ❌ | ✅ |
| Merging | ✅ | ❌ |
| Primitives | ❌ | ✅ |