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 optional chaining bug regarding spread in function calls #8210
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/8452/ |
@@ -83,6 +83,10 @@ export default declare((api, options) => { | |||
} | |||
} | |||
|
|||
if (replacementPath.isOptionalCallExpression()) { | |||
replacementPath.node.type = "CallExpression"; |
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.
Looks good, the type should be changed in the transform for sure? This logic is similar to what was done in https://github.com/babel/babel/pull/8210/files#diff-accf2589ebb96f2b32131e0a1f8a08eaR24
if (objectPath.isOptionalMemberExpression()) {
objectPath.node.type = "MemberExpression";
}
@hzoo Do you have an idea of when this PR will be merged & released ? I came across this issue using a spread operator into an optional chaining method call and the spread operator is invisible for |
Closing this for #9073, which fixes the more general case. I've reused your commits, so you'll still get credit. Thanks for starting it! |
@jridgewell thank you! |
Currently when
proposal-optional-chaining
transformsinto
that last
_a.b()
is technically anOptionalCallExpression
with nooptional
field set.This PR changes it to be just a
CallExpression
. I believe this is how it should be, and this also enables other plugins (liketransform-spread
) who useCallExpression
in their visitors to keep working.