Exclude<T, U>
The utility type that removes from union T every member assignable to U, such as Exclude<HttpMethod, "GET">.
In more detail
Omit removes keys from an object; Exclude removes members from a union. It is a distributive conditional type under the hood.
Related terms
- Extract<T, U> — The utility type that keeps only the members of union T that are assignable to U.
- Omit<T, K> — The utility type that copies type T without the listed keys K, like a denylist of fields.
- distributive conditional type — A conditional type on a bare type parameter, which is applied separately to each member of a union and the results combined.
- union type — A type that allows one of several listed types or values, written with a vertical bar, such as int | None in Python or "small" | "large" in TypeScript.
Taught in
- Conditional Types: Ternary Types And Type Inference With infer — Production TypeScript