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
Inject IIFE when variables shadow binding in rest param #14736
Inject IIFE when variables shadow binding in rest param #14736
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/52453/ |
console.log(Object.keys(t.getBindingIdentifiers(pattern))); | ||
|
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.
console.log(Object.keys(t.getBindingIdentifiers(pattern))); |
); | ||
} | ||
} | ||
|
||
let rest = (node.params.pop() as t.RestElement).argument as |
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.
Q: does rest
always equal to restPath.node
?
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.
Yes, I simplified the code and added a comment in the last commit 👍
7b2108c
to
df261c0
Compare
This is an alternative to #14215, which takes a completely different approach (sorry @The-x-Theorist, I was reviewing&rebasing your PR, and thanks to TS I noticed that the case of "nested bindings" had not been considered 😅)
We already had the logic to handle shadowed function parameters in destructuring/defaults, and this PR re-uses it also for rest params.