0Pricing
TypeScript Academy · Lesson

Distributive Conditional Types

Understand how conditionals distribute over union members.

Welcome

Distributive conditional types apply a conditional type to each member of a union separately. This powerful behavior enables union transformation and filtering.

What Is Distribution

When a conditional type has a bare generic T and T is a union, TypeScript applies the conditional to each union member separately.
type Wrap<T> = T extends any ? { value: T } : never;
type R = Wrap<string | number>;
// = { value: string } | { value: number }

All lessons in this course

  1. keyof and Indexed Access Types
  2. Generic Constraints: Narrowing Type Parameters
  3. Conditional Types: T extends U ? X : Y
  4. Distributive Conditional Types
← Back to TypeScript Academy