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
fix await and yield for do expression #10072
fix await and yield for do expression #10072
Conversation
tanhauhau
commented
Jun 9, 2019
Q | A |
---|---|
Fixed Issues? | Fixes #3780 |
Patch: Bug Fix? | |
Major: Breaking Change? | |
Minor: New Feature? | |
Tests Added + Pass? | Yes |
Documentation PR Link | |
Any Dependency Changes? | |
License | MIT |
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/10961/ |
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/10918/ |
* Check whether the current path contains an `await` expression | ||
*/ | ||
|
||
export function containsAwaitExpression(): boolean { |
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.
You can/should use hasType
instead:
babel/packages/babel-plugin-transform-block-scoping/src/index.js
Lines 572 to 576 in f92c2ae
const hasAsync = traverse.hasType( | |
fn.body, | |
"AwaitExpression", | |
t.FUNCTION_TYPES, | |
); |
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.
Disclaimer: I didn't know about that method until 5 mins ago. Usually, when someone adds a new method to @babel/traverse
there is a 50% probability that it already exists.
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.
I tried to look for it too... But I guess you can find things better than me
Can you disable the failing test on node 6, since it doesn't support async functions? Example: babel/packages/babel-plugin-transform-new-target/test/fixtures/exec/reflect-class/options.json Lines 1 to 3 in eac4c5b
|
Sorry for the bad example, the min node version should be 8 😅 |
Oh wait what was I thinking.. haha |
@nicolo-ribaudo I'm thinking might as well fix for yield generators as well |
I'd prefer it do be done in a separate PR, since there are many more edge cases (e.g. manually calling |
98c0957
to
dcaba6a
Compare
@nicolo-ribaudo fixed the PR |