TypeScript Distributive Conditional Types
TypeScript conditional types choose one type or another based on a type relationship, and they distribute by applying that choice separately to each member of a union. Wrapping the checked type in a tuple suppresses that behavior, letting you test the union as one value.
The problem conditional types solve
A conditional type is a type-level if. It has the form:
type Result<T> = T extends SomeType ? TypeWhenTrue : TypeWhenFalse;
Here, T is a type parameter: a placeholder for a type supplied later. extends asks whether that type is compatible with another type. The two branches after ? and : are the resulting types for the two answers.
For example, an API might accept either a string or a number but return a different representation for each:
type Wrapped<T> = T extends string ? { text: T } : { value: T };
type TextResult = Wrapped<string>; // { text: string }
type NumberResult = Wrapped<number>; // { value: number }
Without conditional types, you could write separate types for known cases, but reusable transformations would become repetitive. Conditional types let one definition preserve the relationship between an input type and its output type.
What distribution means
A union type represents one of several alternatives, such as string | number. When a conditional type checks a naked type parameter—a type parameter used directly on the left side of extends—TypeScript distributes the check across a union.
In other words, this:
type Wrapped<T> = T extends string ? { text: T } : { value: T };
type Result = Wrapped<string | number>;
is treated approximately as:
type Result =
| { text: string }
| { value: number };
It is not treated as one indivisible string | number that must choose one branch. TypeScript effectively evaluates the conditional once with T = string and once with T = number, then unions the results.
This rule applies specifically when the checked side is the type parameter itself:
type A<T> = T extends string ? 1 : 0; // distributive
type B<T> = [T] extends [string] ? 1 : 0; // not distributive
The distinction matters because each member can produce a different result. Distribution preserves information about which input alternatives lead to which output alternatives.
Why distribution is useful
Many type transformations are naturally “run this test on every option.” A common example is filtering a union. TypeScript’s built-in Extract type is effectively defined like this:
type Extract<T, U> = T extends U ? T : never;
never is the type with no possible values. In a union, it contributes nothing, so it acts as a way to discard a member.
That makes this useful for selecting one kind of event from a larger set:
type Event =
| { kind: "click"; x: number; y: number }
| { kind: "key"; key: string }
| { kind: "submit"; formId: string };
type KeyboardEvent = Extract<Event, { kind: "key" }>;
// { kind: "key"; key: string }
The conditional test is applied to each event shape. The key event passes and remains; the other two produce never and disappear.
The built-in Exclude type uses the same pattern in the opposite direction:
type Exclude<T, U> = T extends U ? never : T;
You will encounter this behavior in utility types and in custom types that map, filter, or reshape unions. It is especially valuable for discriminated unions—unions of object types that have a shared property such as kind—because it keeps each alternative’s properties attached to its identifying value.
Suppressing distribution with tuple wrapping
Sometimes the question is not “does each member match?” but “does the entire type, considered as one thing, match?” Put the type parameter inside a one-element tuple on both sides of extends:
type IsString<T> = T extends string ? true : false;
type IsWholeString<T> = [T] extends [string] ? true : false;
type Distributed = IsString<string | number>; // true | false
type Whole = IsWholeString<string | number>; // false
IsString<string | number> distributes: string produces true, and number produces false. The union true | false is usually equivalent to boolean.
IsWholeString<string | number> checks [string | number] against [string] as a single tuple type. Because the union includes number, the complete type is not compatible with string, so the result is simply false.
The tuple is not being used to build a runtime data structure. It changes the shape of the type expression so that the left side is no longer a naked type parameter. TypeScript therefore performs one comparison instead of splitting the union first.
Choosing the behavior
Use the distributive form when each union member should be transformed independently:
type ToArray<T> = T extends unknown ? T[] : never;
type Arrays = ToArray<string | number>; // string[] | number[]
This preserves the alternatives. It is different from (string | number)[], which means one array whose elements may be mixed.
Use tuple wrapping when you need a yes-or-no answer about the union as a whole, or when distributing would produce an unwanted collection of results:
type IsUnionAllowed<T> = [T] extends [string | number] ? true : false;
The practical clue is the conditional’s left side. A naked generic parameter distributes; a wrapped parameter such as [T] does not. Once you recognize that rule, many complex-looking utility types—and many confusing compiler results involving unions—become straightforward type-level if statements evaluated either per alternative or once for the whole type.