What is the difference between distributive and non-distributive conditional types, and how do you create the latter?

TypeScript Professional Hard

TypeScript Professional — Hard

What is the difference between distributive and non-distributive conditional types, and how do you create the latter?

Key points

  • Wrapping type parameters in a tuple prevents distribution
  • Distributive types distribute over unions automatically
  • Non-distributive types evaluate the condition against the whole union
  • Understanding this distinction is crucial for advanced TypeScript usage

Ready to go further?

Related questions