-
Notifications
You must be signed in to change notification settings - Fork 485
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
Format optional types with ? instead of [] #538
Conversation
I like this better. Thanks. I'm still wondering if |
Why bar(a?)
bar(a?: number) ? |
This is matching the Flow syntax ( https://flowtype.org/docs/nullable-types.html ), and also aligns with the rest of the types: the optionality of the parameter is part of its type, and the pattern is |
From https://flowtype.org/docs/builtins.html#null-and-void
As I understand /**
* @param {number} [bar=1]
*/
function foo(bar = 1) {} |
Yep, you're right @ikokostya - thx for checking :) Working on an updated version now. |
cff426e
to
524f4c7
Compare
This is the one corner case right now... since we pass only the param type - not the param - to formatType in the theme, the formatType method doesn't have access to a default value so can't include it in the type. I've changed the |
I'm comfortable with keeping this corner case for now, after exploring alternatives. Those are:
Happy to rethink this in the future or accept a PR of an improvement on this one! |
Fixes #509
Formats optionals with
?
instead of[]
, to avoid confusion with array types.