The "never" type

This is a consequence of the distributive property of conditional types.

Essentially, (S | T) extends A ? B : C is equivalent to (S extends A ? B : C) | (T extends A ? B : C), i.e. the conditional type distributes over the union in the extends clause. Since every type T is equivalent to T | never, it follows that

T extends A ? B : C is equivalent to (T | never) extends A ? B : C, Which in turn is equivalent to (T extends A ? B : C) | (never extends A ? B : C), This is the same as the original type unioned with never extends A ? B : C. So a conditional type of the form never extends A ? B : C must evaluate to never, otherwise the distributive property would be violated.

Was this page helpful?