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 | ExpressionskipTransparentExprWrapperNodes 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-wrappershas a confusing interface.isTransparentExprWrappertakes aNode, whileskipTransparentExprWrapperstook aNodePath.The latter was incorrectly called with a
Nodein@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
skipTransparentExprWrappersto accept either anExpressionorNodePath<Expression>. This fixes the issue in@babel/plugin-proposal-optional-chaining, and also allows using theExpressionoverload in two other places in that plugin where theNodePathis not needed.