Multiple Type Parameters and Distribution
What you'll learn: How distributive conditional types behave when multiple type parameters are involved, and which parameters actually distribute over unions.
The Core Rule
When a conditional type has multiple type parameters, only the type being checked (the one before extends) distributes over unions — and only if it's "naked" (used directly without wrapping).
Other type parameters in the conditional do not distribute, even if they're unions. They're evaluated as-is.
How It Works
// T distributes, U does not
type Filter<T, U> = T extends U ? T : never;
type A = Filter<'a' | 'b' | 'c', 'a' | 'b'>;
// T = 'a' | 'b' | 'c' distributes
// U = 'a' | 'b' stays as a union
// Result: 'a' | 'b'
The conditional distributes only over T, checking each member individually:
'a' extends ('a' | 'b')→'a'✓'b' extends ('a' | 'b')→'b'✓'c' extends ('a' | 'b')→never✗
The Analogy
Think of T as the "item being inspected" that gets unwrapped and checked piece-by-piece. U is the "reference specification" that stays whole — you compare each piece of T against the entire U.
Multiple Type Parameters in Practice
type ExtractMatching<T, U, V> = T extends U ? V : never;
type Result = ExtractMatching<'x' | 'y', string, number>;
// T distributes: 'x' extends string → number
// 'y' extends string → number
// U and V don't distribute
// Result: number | number → number
Key Takeaway: In conditional types with multiple type parameters, only the checked type (before extends) distributes over unions. All other type parameters are used as complete, non-distributed types in the condition and branches.