-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
Why an Option type instead of type
| undefined?
#87
Comments
I looked more into it, as For |
probably because Option handles |
Then you can just expand the union to |
It abstracts the absence of a given type T. You could think of it as just an alias for type representation in raw typescript: T|null|undefined, but there's little more about it. BTW, I understand there are some issues with functions that take options as arguments are easy to cause an error, since the type signature says it takes option type(which should be T| null | undefined), but only works properly when it takes |
Hey, this is a question instead of a real issue, but the discussion tab isnt present.
So I am wondering why you use an
Option
-Type instead of simply using a union type of<provided type> | undefined
?Because with the specific type you always need to wrap the value first instead of just using the functions.
I am not saying that one is better than the other, but simply curious :D
The text was updated successfully, but these errors were encountered: