convert @babel/helper-skip-transparent-expression-wrappers to typescript#13640
convert @babel/helper-skip-transparent-expression-wrappers to typescript#13640lightmare wants to merge 1 commit intobabel:mainfrom
Conversation
* overload skipTransparentExprWrappers * fixes isSimpleMemberExpression in @babel/plugin-proposal-optional-chaining * use skipTransparentExprWrappers<Expression> instead of the NodePath overload where possible in @babel/plugin-proposal-optional-chaining
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/47975/ |
|
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 61b6b16:
|
They are just internal types, we don't publish them yet. |
| export function skipTransparentExprWrappers(expr: t.Expression): t.Expression; | ||
|
|
||
| export function skipTransparentExprWrappers( | ||
| expr: NodePath<t.Expression>, | ||
| ): NodePath<t.Expression>; |
There was a problem hiding this comment.
We could also just expose two functions (skipTransparentExprWrappers and skipTransparentExprWrappersNodes); lets see what other team members think.
There was a problem hiding this comment.
Agree.
@lightmare Can you split this PR? One for JS->TS and the other with a new API? So we can merge the JS->TS in patch releases.
@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-chainig: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.