Built-in Conditional Types
This lesson walks through several of TypeScript's built-in conditional types and explains them in detail.
Exclude
Exclude
takes a union type, T
, and removes the members that are assignable to U
. It’s another example of the distributiveness of conditional types. For all union members that extend U
, the conditional expression will return never
. The result will be a union of the remaining members.
Exclude
is particularly useful when combined with the keyof
operator. If you’re not familiar with it, keyof
takes an interface and returns a ...