Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

NonNullable<Type> #10

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

NonNullable<Type> #10

nmsn opened this issue Dec 6, 2022 · 1 comment

Comments

@nmsn
Copy link
Contributor

nmsn commented Dec 6, 2022

Constructs a type by excluding null and undefined from Type.

type T0 = NonNullable<string | number | undefined>;
// type T0 = string | number

type T1 = NonNullable<string[] | null | undefined>;
// type T1 = string[]
@nmsn nmsn added the TypeScript label Dec 6, 2022
@nmsn
Copy link
Contributor Author

nmsn commented Dec 6, 2022

/**
 * Exclude null and undefined from T
 */
type NonNullable<T> = T & {};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant