Avoiding Intersection Overuse
You'll learn when intersections add unnecessary complexity and how to choose simpler alternatives.
Intersection types are powerful, but they're not always the best tool. Just because you can combine types with & doesn't mean you should. Overusing intersections often creates types that are harder to read, debug, and maintain than simpler alternatives.
When Intersections Add Complexity Without Benefit
Consider this overly-complex example:
type User = { name: string };
type WithId = { id: number };
type WithTimestamps = { created: Date; updated: Date };
// Intersection overuse:
type UserRecord = User & WithId & WithTimestamps;
This works, but it's harder to understand than a straightforward interface:
interface UserRecord {
name: string;
id: number;
created: Date;
updated: Date;
}
The interface version is clearer, easier to extend, and provides better error messages.
Choose the Simpler Path
Use intersections when:
- Combining truly independent concerns (like adding capabilities to existing types)
- Working with generics where you need to merge constraints
- Implementing mixins or composing behaviors
Avoid intersections when:
- You're just defining a regular object shape → use an interface
- Interface extension would work → use
extendsinstead - You're intersecting many small types → combine them into one cohesive type
Think of intersections like glue: essential for joining separate pieces, but if you're "gluing" things that belong together naturally, you're overcomplicating. A chair isn't four legs glued to a seat glued to a back — it's designed as a unified object.
Key Takeaway: Reach for intersections when composing independent capabilities, but prefer interfaces or type aliases for straightforward object shapes. Simpler type definitions are easier to understand and maintain.