-
Notifications
You must be signed in to change notification settings - Fork 642
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
A version of types.maybe
which uses undefined
instead of null
#830
Comments
you have types.optional, which is i think what you look for |
Yes, you can implement it with function maybeUndefined<S, T>(type: IType<S, T>): IType<S | undefined, T | undefined> {
return types.optional(types.union(type, types.undefined), undefined);
} but it would be cool if it were built in 🙂 |
I think it would be interesting to consider dropping |
It seems to me that we could introduce ‘types.nullable’ as direct replacement of current ‘maybe’, and convert ‘maybe’’s default to ‘undefined’, as proposed in previous comment |
Done! In MST 3 |
This doc need an update stating this change? |
In TypeScript especially,
undefined
is almost always preferable tonull
as a representation of unset values, so it would be nice if there was a version oftypes.maybe
(types.maybeUndefined
?) which usedundefined
instead ofnull
.The text was updated successfully, but these errors were encountered: