What Makes a Conditional Type Distributive
You'll learn: What triggers TypeScript to automatically distribute conditional types over union members and how naked type parameters make this happen.
The Core Concept
You've seen conditional types distribute over unions in the previous lesson, but why does that happen? The answer lies in a specific pattern: naked type parameters.
A conditional type is distributive when:
- The checked type (before
extends) is a naked type parameter - The type parameter is instantiated with a union type
A naked type parameter means the type parameter appears directly, without being wrapped in any other type structure like an array, tuple, or object.
Naked vs Non-Naked
// Naked T — WILL distribute
type Distributive<T> = T extends string ? T[] : never;
// Wrapped T — will NOT distribute
type NonDistributive<T> = [T] extends [string] ? T[] : never;
// Test with a union
type Test1 = Distributive<string | number>;
// Distributes: (string extends string ? string[] : never) | (number extends string ? number[] : never)
// Result: string[]
type Test2 = NonDistributive<string | number>;
// Does NOT distribute: [string | number] extends [string] ? ...
// Result: never
In Distributive<T>, T stands alone—it's naked. In NonDistributive<T>, T is wrapped in a tuple [T], so the union is checked as a whole.
The Role of Naked Type Parameters
Think of naked type parameters as triggers. When TypeScript sees T extends ... where T is:
- Directly exposed (naked): Apply the conditional to each union member separately
- Wrapped in a structure: Treat the entire union as one type
This is why filtering patterns work so elegantly with naked type parameters—each union member gets its own conditional check.
Key Takeaway: Conditional types distribute over unions only when the checked type is a naked type parameter; wrapping the parameter prevents distribution and checks the union as a whole.