Overview - Non-distributive conditional types
What is it?
Non-distributive conditional types in TypeScript are conditional types that do not automatically split or distribute over union types. Normally, conditional types in TypeScript distribute over each member of a union, but non-distributive conditional types prevent this behavior, allowing you to treat the union as a whole. This helps when you want to apply a condition to the entire union type rather than each part separately.
Why it matters
Without non-distributive conditional types, TypeScript would always break down unions and apply conditions to each member, which can lead to unexpected or unwanted results. This makes it hard to write precise type logic when you want to handle unions as a single entity. Non-distributive conditional types solve this by giving you control over how conditions apply, improving type safety and expressiveness in complex type scenarios.
Where it fits
Before learning non-distributive conditional types, you should understand basic TypeScript types, union types, and how conditional types work with distribution. After mastering this, you can explore advanced type manipulations like mapped types, template literal types, and recursive conditional types.