When to Use Intersections
You'll learn when intersection types are the right tool for the job and when to reach for them instead of other TypeScript features.
The Core Idea
Intersection types (&) shine in three main scenarios: composing behaviors from multiple sources, mixing in properties to extend existing types, and combining independent type requirements that must all be satisfied simultaneously.
Think of intersections like assembling a team where each member brings different skills. You're not creating a hierarchy (like inheritance), you're saying "we need someone who can do X and Y and Z."
Composing Behaviors
When you have separate, reusable pieces of functionality that should combine:
type Loggable = { log: () => void };
type Serializable = { toJSON: () => string };
type AuditRecord = Loggable & Serializable & {
timestamp: Date;
};
Each concern is independent. An AuditRecord must satisfy all three contracts.
Mixing in Properties
Adding capabilities to existing types without modifying them:
type User = { id: number; name: string };
type Timestamped = { createdAt: Date; updatedAt: Date };
type PersistedUser = User & Timestamped;
This is cleaner than redefining all properties or forcing User to change.
Combining Independent Requirements
When a function needs an argument that meets multiple, unrelated constraints:
type HasId = { id: string };
type HasName = { name: string };
function displayEntity(entity: HasId & HasName) {
return `${entity.name} (${entity.id})`;
}
The function doesn't care about the object's full shape—just that it has both properties.
Key Takeaway: Use intersections when you need to combine independent, orthogonal type requirements rather than modeling hierarchical relationships—they're perfect for composition over inheritance patterns.