Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Exclude<UnionType, ExcludedMembers> #8

Open
nmsn opened this issue Dec 5, 2022 · 1 comment
Open

Exclude<UnionType, ExcludedMembers> #8

nmsn opened this issue Dec 5, 2022 · 1 comment

Comments

@nmsn
Copy link
Contributor

nmsn commented Dec 5, 2022

Constructs a type by excluding from UnionType all union members that are assignable to ExcludedMembers.

type T0 = Exclude<"a" | "b" | "c", "a">;
type T0 = "b" | "c"

type T1 = Exclude<"a" | "b" | "c", "a" | "b">;
type T1 = "c"

type T2 = Exclude<string | number | (() => void), Function>;
@nmsn nmsn added the TypeScript label Dec 5, 2022
@nmsn
Copy link
Contributor Author

nmsn commented Dec 5, 2022

/**
 * Exclude from T those types that are assignable to U
 */
type Exclude<T, U> = T extends U ? never : T;

@nmsn nmsn mentioned this issue Dec 6, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

1 participant