Course contentsShow
← TypeScript
Lesson 1719 of 1,79639. TypeScript PerformanceFree lesson

Intersection Type Resolution Costs

Why complex intersections require expensive type normalization and conflict checking.

Intersection Type Resolution Costs

What you'll learn: Why intersection types can become surprisingly expensive for the TypeScript compiler to resolve, especially when they involve complex or conflicting properties.

Why Intersections Aren't Free

When you write an intersection type like A & B, TypeScript doesn't just slap two types together — it performs type normalization to figure out what the resulting type actually looks like. This involves checking every property from both types, resolving conflicts, and computing the final shape.

For simple intersections, this is cheap. But when your intersections grow complex — deeply nested objects, large unions within them, or multiple intersecting types — the compiler must do exponential work.

The Two Expensive Operations

1. Conflict Checking

TypeScript must verify that properties with the same name are compatible. If A has value: string and B has value: number, the intersection resolves to never because no value can satisfy both. Determining this requires checking every overlapping property.

2. Type Normalization

The compiler attempts to simplify and normalize the intersection into a canonical form. This involves expanding mapped types, distributing unions, and recursively resolving nested intersections. Each layer multiplies the computational cost.

When Costs Explode

Large object types with many properties, intersected with other large object types, create a combinatorial explosion. The compiler must compare every property pair. If those properties themselves contain complex unions or conditional types, resolution time skyrockets.

Recursive intersections (types that reference themselves through intersections) can hit depth limits or cause the compiler to repeatedly attempt resolution until it gives up or times out.

Key Takeaway: Complex intersections with many properties, nested structures, or conflicting types force TypeScript to perform expensive normalization and conflict-checking operations that can significantly slow down compilation.