Conceptual
Login

Distributive Conditional Types

When the checked type is a naked type parameter, a conditional type maps over each member of a union independently: Exclude<A | B, B> becomes (A extends B ? never : A) | (B extends B ? never : B). Wrapping both sides in a one-tuple ([T] extends [U]) disables distribution when you need to test the union as a whole.

This Concept is waiting for its first lesson!

When the checked type is a naked type parameter, a conditional type maps over each member of a union independently: Exclude<A | B, B> becomes (A extends B ? never : A) | (B extends B ? never : B). Wrapping both sides in a one-tuple ([T] extends [U]) disables distribution when you need to test the union as a whole.

Are you a teacher? Sign in to start contributing.

Sign In