Maybe types #144
Closed
gustavopch
started this conversation in
Ideas
Maybe types
#144
Replies: 2 comments 5 replies
-
Thanks for the suggestion, this is definitely something I've felt the need for myself. Reading the Flow docs it looks like it should also make parameters optional to be completely compatible with Flow semantics.
|
Beta Was this translation helpful? Give feedback.
4 replies
-
We've been discussing this more on Discord. There are at least two decisions to make:
We could imagine compiler flags to control which null values get OR'd. Or |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In many cases, the distinction between
null
andundefined
is not important and the code ends up with lots of| null | undefined
, so I propose that?string
be expanded tostring | null | undefined
as supported by Flow: https://flow.org/en/docs/types/maybe/.Together with #126, we'll be able to write something like:
Instead of:
Beta Was this translation helpful? Give feedback.
All reactions