Skip to content

Commit

Permalink
Fix optional calls astring generation (#5733)
Browse files Browse the repository at this point in the history
* test

* Fix

* Copy-paste mishap...
  • Loading branch information
mischnic authored Jan 28, 2021
1 parent a8f5567 commit 40f2417
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/core/integration-tests/test/babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,6 @@ describe('babel', function() {

let output = await run(b);
assert.equal(typeof output, 'object');
assert.equal(output.default, undefined);
assert.deepEqual(output.default, [undefined, undefined]);
});
});
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
let a;
export default a?.b;
let a, x;
export default [a?.b, x?.()];
6 changes: 5 additions & 1 deletion packages/shared/babel-ast-utils/src/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,11 @@ export const generator = {
OptionalCallExpression(node, state) {
node.optional = true;
node.type = 'CallExpression';
this.CallExpression(node, state, true);
baseGenerator.CallExpression.call(this, node, state);
},
CallExpression(node, state) {
if (node.optional) node.optional = false;
baseGenerator.CallExpression.call(this, node, state);
},
ExportNamedDeclaration(node, state) {
if (node.source) {
Expand Down

0 comments on commit 40f2417

Please sign in to comment.