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
Flow: Fix generating arrow functions with param #4504
Conversation
Current coverage is 88.32% (diff: 100%)@@ master #4504 diff @@
==========================================
Files 194 194
Lines 13609 13612 +3
Methods 1426 1427 +1
Messages 0 0
Branches 3145 3146 +1
==========================================
+ Hits 12020 12023 +3
Misses 1589 1589
Partials 0 0
|
|
||
if ( | ||
node.params.length === 1 | ||
&& t.isIdentifier(param = node.params[0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be confusing to read to some but makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yeah, idk why I didn't assign it immediately. I've pushed a change for that (and extracted the type checking into a function to be explicit).
Awesome |
👍 Thanks alot |
🎉 great stuff |
* transform-flow-comments, single arrow param support babel#4503 * further tests for printing single arrow func param flow code * cleanup
Fixes:
transform-flow-comments
single arrow param would not print type (babel-plugin-transform-flow-comments does not preserve types for single parameter lambda functions #4503)transform-flow-comments
single arrow param would not print optional (babel-plugin-transform-flow-comments failing for ? optional/maybe (T7249) #4211)I also found just using
syntax-flow
wouldn't print out types/optionals for arrow functions with a single param. e.g. all of these:(only when they have a single param) output:
The output now correctly matches the input.