Distributive Property Limitations
What you'll learn: Why intersections don't automatically distribute over unions like you might expect from algebra, and how to work around it.
In algebra, multiplication distributes over addition: a × (b + c) = (a × b) + (a × c). You might expect TypeScript intersections to work the same way over unions, but they don't automatically distribute.
The Non-Distributive Reality
When you write A & (B | C), TypeScript does not automatically transform this into (A & B) | (A & C). It keeps the intersection "outside" the union:
type A = { name: string };
type B = { age: number };
type C = { age: string };
type Result = A & (B | C);
// This is NOT the same as (A & B) | (A & C)
// TypeScript keeps it as-is: A intersected with the union of B|C
This matters because TypeScript evaluates the types structurally. A & (B | C) means "an object that satisfies A AND satisfies either B or C" — but TypeScript won't decompose it for you.
Why This Causes Problems
The age property in B | C creates a union: number | string. When intersected with A, you get:
// Result has type:
// { name: string; age: number | string }
If you wanted distribution, you'd need to write it manually:
type Distributed = (A & B) | (A & C);
// This gives: { name: string; age: number } | { name: string; age: string }
Notice the difference: the distributed version preserves the separation — age is number in one branch and string in the other, not merged into number | string.
Workarounds
When you need distributive behavior, explicitly write the distributed form or use conditional types (covered later). For now, recognize that intersections don't distribute and plan your type combinations accordingly.
Key Takeaway: Intersections don't distribute over unions automatically — A & (B | C) stays as-is unless you manually rewrite it as (A & B) | (A & C).