Exclude<T, U>

Constructs a type by excluding from T all union members assignable to U.

Since TS 2.8 Spec ↗

Syntax

Exclude<UnionType, ExcludedMembers>

Returns

union type — The union T with every member assignable to U removed.

Examples

type T = 'a' | 'b' | 'c';
type Result = Exclude<T, 'a'>; // 'b' | 'c'
type NonFn = Exclude<string | number | (() => void), Function>;
// string | number

Notes

Defined as a distributive conditional type: `T extends U ? never : T`. Operates on each union member individually. Use `Omit` to drop object keys and `Extract` for the complementary operation.

See also