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
add skipTransparentExprWrapperNodes
helper
#13687
add skipTransparentExprWrapperNodes
helper
#13687
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/48309/ |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 8f26798:
|
Hey @lightmare, can you rebase please? |
* fixes isSimpleMemberExpression in @babel/plugin-proposal-optional-chaining * use skipTransparentExprWrappers<Expression> instead of the NodePath overload where possible in @babel/plugin-proposal-optional-chaining
f422c3c
to
fad4759
Compare
There's an E2E failure that seems related, it throws: It looks like The only explanation I could come up with is that the But it's weird, this is not the only place where |
The |
Thank you for the explanation. I guess the best solution will be to add a separate method instead of overloading. |
This reverts commit fad4759.
* avoids constructing NodePaths when only the Node is needed * fixes isSimpleMemberExpression in @babel/plugin-proposal-optional-chaining * use this new helper instead of skipTransparentExprWrappers where possible in @babel/plugin-proposal-optional-chaining
I have reverted the overload patch, and pushed a new version with a separate function. |
Didn't we "recently" merged another helper with |
skipTransparentExprWrappers
for NodePath | Expression
skipTransparentExprWrapperNodes
helper
Should I squash the commits in the branch, or will you just squash it during merge? |
@lightmare We use Squash and merge most of time. So you are all set. |
Requires #13686
Description copied from #13640 :
@babel/helper-skip-transparent-expression-wrappers
has a confusing interface.isTransparentExprWrapper
takes aNode
, whileskipTransparentExprWrappers
took aNodePath
.The latter was incorrectly called with a
Node
in@babel/plugin-proposal-optional-chaining
:babel/packages/babel-plugin-proposal-optional-chaining/src/transform.js
Line 11 in b2d9156
Consequently, optional call in loose mode produced temp variables when it shouldn't, as in this test:
babel/packages/babel-plugin-proposal-optional-chaining/test/fixtures/transparent-expr-wrappers/ts-as-function-call-loose/output.js
Line 3 in b2d9156
This PR overloads
skipTransparentExprWrappers
to accept either anExpression
orNodePath<Expression>
. This fixes the issue in@babel/plugin-proposal-optional-chaining
, and also allows using theExpression
overload in two other places in that plugin where theNodePath
is not needed.