diff --git a/packages/babel-generator/test/fixtures/regression/comment-before-parentheses-return-arg-createParenthesizedExpressions/input.js b/packages/babel-generator/test/fixtures/regression/comment-before-parentheses-return-arg-createParenthesizedExpressions/input.js new file mode 100644 index 000000000000..a3cf0a4be64d --- /dev/null +++ b/packages/babel-generator/test/fixtures/regression/comment-before-parentheses-return-arg-createParenthesizedExpressions/input.js @@ -0,0 +1,17 @@ +function assertElement(assertFn, shouldBeElement, opt_message) { + return /** @type {!Ele ment} */ ( + assertType_( + assertFn, + shouldBeElement, + isElement(shouldBeElement), + 'Element expected', + opt_message + ) + ); +} + +const slot = /** @type {!HTMLSlotElement} */ (e.target); + +assertElement( + /** @type {Element} */ (el), +); diff --git a/packages/babel-generator/test/fixtures/regression/comment-before-parentheses-return-arg-createParenthesizedExpressions/options.json b/packages/babel-generator/test/fixtures/regression/comment-before-parentheses-return-arg-createParenthesizedExpressions/options.json new file mode 100644 index 000000000000..2e2a41c80ee5 --- /dev/null +++ b/packages/babel-generator/test/fixtures/regression/comment-before-parentheses-return-arg-createParenthesizedExpressions/options.json @@ -0,0 +1,4 @@ +{ + "retainLines": true, + "createParenthesizedExpressions": true +} diff --git a/packages/babel-generator/test/fixtures/regression/comment-before-parentheses-return-arg-createParenthesizedExpressions/output.js b/packages/babel-generator/test/fixtures/regression/comment-before-parentheses-return-arg-createParenthesizedExpressions/output.js new file mode 100644 index 000000000000..2d75ee0d3db8 --- /dev/null +++ b/packages/babel-generator/test/fixtures/regression/comment-before-parentheses-return-arg-createParenthesizedExpressions/output.js @@ -0,0 +1,16 @@ +function assertElement(assertFn, shouldBeElement, opt_message) { + return (/** @type {!Ele ment} */ + assertType_( + assertFn, + shouldBeElement, + isElement(shouldBeElement), + 'Element expected', + opt_message)); + + +} + +const slot = /** @type {!HTMLSlotElement} */e.target; + +assertElement( +/** @type {Element} */el); \ No newline at end of file diff --git a/packages/babel-generator/test/fixtures/regression/comment-before-parentheses-return-arg/input.js b/packages/babel-generator/test/fixtures/regression/comment-before-parentheses-return-arg/input.js new file mode 100644 index 000000000000..a3cf0a4be64d --- /dev/null +++ b/packages/babel-generator/test/fixtures/regression/comment-before-parentheses-return-arg/input.js @@ -0,0 +1,17 @@ +function assertElement(assertFn, shouldBeElement, opt_message) { + return /** @type {!Ele ment} */ ( + assertType_( + assertFn, + shouldBeElement, + isElement(shouldBeElement), + 'Element expected', + opt_message + ) + ); +} + +const slot = /** @type {!HTMLSlotElement} */ (e.target); + +assertElement( + /** @type {Element} */ (el), +); diff --git a/packages/babel-generator/test/fixtures/regression/comment-before-parentheses-return-arg/output.js b/packages/babel-generator/test/fixtures/regression/comment-before-parentheses-return-arg/output.js new file mode 100644 index 000000000000..24a35efbd7b6 --- /dev/null +++ b/packages/babel-generator/test/fixtures/regression/comment-before-parentheses-return-arg/output.js @@ -0,0 +1,13 @@ +function assertElement(assertFn, shouldBeElement, opt_message) { + return ( + /** @type {!Ele ment} */ + assertType_(assertFn, shouldBeElement, isElement(shouldBeElement), 'Element expected', opt_message) + ); +} + +const slot = +/** @type {!HTMLSlotElement} */ +e.target; +assertElement( +/** @type {Element} */ +el); \ No newline at end of file diff --git a/packages/babel-parser/src/parser/comments.js b/packages/babel-parser/src/parser/comments.js index e6dc327e1f38..8ffb40ddb18c 100644 --- a/packages/babel-parser/src/parser/comments.js +++ b/packages/babel-parser/src/parser/comments.js @@ -26,6 +26,7 @@ export type CommentWhitespace = { trailingNode: Node | null, containingNode: Node | null, }; + /** * Merge comments with node's trailingComments or assign comments to be * trailingComments. New comments will be placed before old comments @@ -42,6 +43,22 @@ function setTrailingComments(node: Node, comments: Array) { } } +/** + * Merge comments with node's leadingComments or assign comments to be + * leadingComments. New comments will be placed before old comments + * because the commentStack is enumerated reversely. + * + * @param {Node} node + * @param {Array} comments + */ +function setLeadingComments(node: Node, comments: Array) { + if (node.leadingComments === undefined) { + node.leadingComments = comments; + } else { + node.leadingComments.unshift(...comments); + } +} + /** * Merge comments with node's innerComments or assign comments to be * innerComments. New comments will be placed before old comments @@ -50,10 +67,10 @@ function setTrailingComments(node: Node, comments: Array) { * @param {Node} node * @param {Array} comments */ -export function setInnerComments(node: Node, comments: Array | void) { +export function setInnerComments(node: Node, comments: Array) { if (node.innerComments === undefined) { node.innerComments = comments; - } else if (comments !== undefined) { + } else { node.innerComments.unshift(...comments); } } @@ -149,7 +166,7 @@ export default class CommentsParser extends BaseParser { setTrailingComments(commentWS.leadingNode, comments); } if (commentWS.trailingNode !== null) { - commentWS.trailingNode.leadingComments = comments; + setLeadingComments(commentWS.trailingNode, comments); } } else { /*:: invariant(commentWS.containingNode !== null) */ @@ -238,4 +255,36 @@ export default class CommentsParser extends BaseParser { commentWS.leadingNode = null; } } + + /** + * Attach a node to the comment whitespaces right before/after + * the given range. + * + * This is used to properly attach comments around parenthesized + * expressions as leading/trailing comments of the inner expression. + * + * @param {Node} node + * @param {number} start + * @param {number} end + */ + takeSurroundingComments(node: Node, start: number, end: number) { + const { commentStack } = this.state; + const commentStackLength = commentStack.length; + if (commentStackLength === 0) return; + let i = commentStackLength - 1; + + for (; i >= 0; i--) { + const commentWS = commentStack[i]; + const commentEnd = commentWS.end; + const commentStart = commentWS.start; + + if (commentStart === end) { + commentWS.leadingNode = node; + } else if (commentEnd === start) { + commentWS.trailingNode = node; + } else if (commentEnd < start) { + break; + } + } + } } diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index 6eb1d69c12d7..4dcd64a5d6e7 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -1023,9 +1023,13 @@ export default class ExpressionParser extends LValParser { call.extra?.trailingComma, ); // mark inner comments of `async()` as inner comments of `async () =>` - setInnerComments(node, call.innerComments); + if (call.innerComments) { + setInnerComments(node, call.innerComments); + } // mark trailing comments of `async` to be inner comments - setInnerComments(node, call.callee.trailingComments); + if (call.callee.trailingComments) { + setInnerComments(node, call.callee.trailingComments); + } return node; } @@ -1738,6 +1742,9 @@ export default class ExpressionParser extends LValParser { if (!this.options.createParenthesizedExpressions) { this.addExtra(val, "parenthesized", true); this.addExtra(val, "parenStart", startPos); + + this.takeSurroundingComments(val, startPos, this.state.lastTokEnd); + return val; } diff --git a/packages/babel-parser/test/fixtures/comments/basic/nested-parentheses/input.js b/packages/babel-parser/test/fixtures/comments/basic/nested-parentheses/input.js new file mode 100644 index 000000000000..aac44abb2fcd --- /dev/null +++ b/packages/babel-parser/test/fixtures/comments/basic/nested-parentheses/input.js @@ -0,0 +1 @@ +1 + /* 0 */(/* 1 */(/* 2 */(/* 3 */i/* 4 */)/* 5 */)/* 6 */)/* 7 */; diff --git a/packages/babel-parser/test/fixtures/comments/basic/nested-parentheses/output.json b/packages/babel-parser/test/fixtures/comments/basic/nested-parentheses/output.json new file mode 100644 index 000000000000..a6768b2cd357 --- /dev/null +++ b/packages/babel-parser/test/fixtures/comments/basic/nested-parentheses/output.json @@ -0,0 +1,128 @@ +{ + "type": "File", + "start":0,"end":68,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":68}}, + "program": { + "type": "Program", + "start":0,"end":68,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":68}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":68,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":68}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":60,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":60}}, + "left": { + "type": "NumericLiteral", + "start":0,"end":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + }, + "operator": "+", + "right": { + "type": "Identifier", + "start":35,"end":36,"loc":{"start":{"line":1,"column":35},"end":{"line":1,"column":36},"identifierName":"i"}, + "name": "i", + "extra": { + "parenthesized": true, + "parenStart": 11 + }, + "trailingComments": [ + { + "type": "CommentBlock", + "value": " 4 ", + "start":36,"end":43,"loc":{"start":{"line":1,"column":36},"end":{"line":1,"column":43}} + }, + { + "type": "CommentBlock", + "value": " 5 ", + "start":44,"end":51,"loc":{"start":{"line":1,"column":44},"end":{"line":1,"column":51}} + }, + { + "type": "CommentBlock", + "value": " 6 ", + "start":52,"end":59,"loc":{"start":{"line":1,"column":52},"end":{"line":1,"column":59}} + } + ], + "leadingComments": [ + { + "type": "CommentBlock", + "value": " 0 ", + "start":4,"end":11,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":11}} + }, + { + "type": "CommentBlock", + "value": " 1 ", + "start":12,"end":19,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":19}} + }, + { + "type": "CommentBlock", + "value": " 2 ", + "start":20,"end":27,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":27}} + }, + { + "type": "CommentBlock", + "value": " 3 ", + "start":28,"end":35,"loc":{"start":{"line":1,"column":28},"end":{"line":1,"column":35}} + } + ] + }, + "trailingComments": [ + { + "type": "CommentBlock", + "value": " 7 ", + "start":60,"end":67,"loc":{"start":{"line":1,"column":60},"end":{"line":1,"column":67}} + } + ] + } + } + ], + "directives": [] + }, + "comments": [ + { + "type": "CommentBlock", + "value": " 0 ", + "start":4,"end":11,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":11}} + }, + { + "type": "CommentBlock", + "value": " 1 ", + "start":12,"end":19,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":19}} + }, + { + "type": "CommentBlock", + "value": " 2 ", + "start":20,"end":27,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":27}} + }, + { + "type": "CommentBlock", + "value": " 3 ", + "start":28,"end":35,"loc":{"start":{"line":1,"column":28},"end":{"line":1,"column":35}} + }, + { + "type": "CommentBlock", + "value": " 4 ", + "start":36,"end":43,"loc":{"start":{"line":1,"column":36},"end":{"line":1,"column":43}} + }, + { + "type": "CommentBlock", + "value": " 5 ", + "start":44,"end":51,"loc":{"start":{"line":1,"column":44},"end":{"line":1,"column":51}} + }, + { + "type": "CommentBlock", + "value": " 6 ", + "start":52,"end":59,"loc":{"start":{"line":1,"column":52},"end":{"line":1,"column":59}} + }, + { + "type": "CommentBlock", + "value": " 7 ", + "start":60,"end":67,"loc":{"start":{"line":1,"column":60},"end":{"line":1,"column":67}} + } + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/comments/basic/sequence-expression/output.json b/packages/babel-parser/test/fixtures/comments/basic/sequence-expression/output.json index 4a3317680493..751c64eda232 100644 --- a/packages/babel-parser/test/fixtures/comments/basic/sequence-expression/output.json +++ b/packages/babel-parser/test/fixtures/comments/basic/sequence-expression/output.json @@ -24,22 +24,15 @@ "start":77,"end":84,"loc":{"start":{"line":1,"column":77},"end":{"line":1,"column":84}} } ], - "innerComments": [ - { - "type": "CommentBlock", - "value": " 2 ", - "start":9,"end":16,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":16}} - }, - { - "type": "CommentBlock", - "value": " 8 ", - "start":68,"end":75,"loc":{"start":{"line":1,"column":68},"end":{"line":1,"column":75}} - } - ], "expression": { "type": "SequenceExpression", "start":27,"end":47,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":47}}, "leadingComments": [ + { + "type": "CommentBlock", + "value": " 2 ", + "start":9,"end":16,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":16}} + }, { "type": "CommentBlock", "value": " 3 ", @@ -51,6 +44,11 @@ "type": "CommentBlock", "value": " 7 ", "start":58,"end":65,"loc":{"start":{"line":1,"column":58},"end":{"line":1,"column":65}} + }, + { + "type": "CommentBlock", + "value": " 8 ", + "start":68,"end":75,"loc":{"start":{"line":1,"column":68},"end":{"line":1,"column":75}} } ], "extra": { diff --git a/packages/babel-parser/test/fixtures/comments/regression/13750/input.js b/packages/babel-parser/test/fixtures/comments/regression/13750/input.js new file mode 100644 index 000000000000..0c51bab835d9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/comments/regression/13750/input.js @@ -0,0 +1,5 @@ +if (args[0] === 1 || /* istanbul ignore next */ (args[0] === 2 || args[0] === 3)) { + output = args[0] + 10; +} else { + output = 20; +} diff --git a/packages/babel-parser/test/fixtures/comments/regression/13750/output.json b/packages/babel-parser/test/fixtures/comments/regression/13750/output.json new file mode 100644 index 000000000000..4c46bf5f0f32 --- /dev/null +++ b/packages/babel-parser/test/fixtures/comments/regression/13750/output.json @@ -0,0 +1,228 @@ +{ + "type": "File", + "start":0,"end":136,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":1}}, + "program": { + "type": "Program", + "start":0,"end":136,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":1}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "IfStatement", + "start":0,"end":136,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":1}}, + "test": { + "type": "LogicalExpression", + "start":4,"end":82,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":82}}, + "left": { + "type": "BinaryExpression", + "start":4,"end":17,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":17}}, + "left": { + "type": "MemberExpression", + "start":4,"end":11,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":11}}, + "object": { + "type": "Identifier", + "start":4,"end":8,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":8},"identifierName":"args"}, + "name": "args" + }, + "computed": true, + "property": { + "type": "NumericLiteral", + "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10}}, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + }, + "operator": "===", + "right": { + "type": "NumericLiteral", + "start":16,"end":17,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":17}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + }, + "operator": "||", + "right": { + "type": "LogicalExpression", + "start":50,"end":81,"loc":{"start":{"line":1,"column":50},"end":{"line":1,"column":81}}, + "left": { + "type": "BinaryExpression", + "start":50,"end":63,"loc":{"start":{"line":1,"column":50},"end":{"line":1,"column":63}}, + "left": { + "type": "MemberExpression", + "start":50,"end":57,"loc":{"start":{"line":1,"column":50},"end":{"line":1,"column":57}}, + "object": { + "type": "Identifier", + "start":50,"end":54,"loc":{"start":{"line":1,"column":50},"end":{"line":1,"column":54},"identifierName":"args"}, + "name": "args" + }, + "computed": true, + "property": { + "type": "NumericLiteral", + "start":55,"end":56,"loc":{"start":{"line":1,"column":55},"end":{"line":1,"column":56}}, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + }, + "operator": "===", + "right": { + "type": "NumericLiteral", + "start":62,"end":63,"loc":{"start":{"line":1,"column":62},"end":{"line":1,"column":63}}, + "extra": { + "rawValue": 2, + "raw": "2" + }, + "value": 2 + } + }, + "operator": "||", + "right": { + "type": "BinaryExpression", + "start":68,"end":81,"loc":{"start":{"line":1,"column":68},"end":{"line":1,"column":81}}, + "left": { + "type": "MemberExpression", + "start":68,"end":75,"loc":{"start":{"line":1,"column":68},"end":{"line":1,"column":75}}, + "object": { + "type": "Identifier", + "start":68,"end":72,"loc":{"start":{"line":1,"column":68},"end":{"line":1,"column":72},"identifierName":"args"}, + "name": "args" + }, + "computed": true, + "property": { + "type": "NumericLiteral", + "start":73,"end":74,"loc":{"start":{"line":1,"column":73},"end":{"line":1,"column":74}}, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + }, + "operator": "===", + "right": { + "type": "NumericLiteral", + "start":80,"end":81,"loc":{"start":{"line":1,"column":80},"end":{"line":1,"column":81}}, + "extra": { + "rawValue": 3, + "raw": "3" + }, + "value": 3 + } + }, + "extra": { + "parenthesized": true, + "parenStart": 49 + }, + "leadingComments": [ + { + "type": "CommentBlock", + "value": " istanbul ignore next ", + "start":22,"end":48,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":48}} + } + ] + } + }, + "consequent": { + "type": "BlockStatement", + "start":84,"end":112,"loc":{"start":{"line":1,"column":84},"end":{"line":3,"column":1}}, + "body": [ + { + "type": "ExpressionStatement", + "start":88,"end":110,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":24}}, + "expression": { + "type": "AssignmentExpression", + "start":88,"end":109,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":23}}, + "operator": "=", + "left": { + "type": "Identifier", + "start":88,"end":94,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":8},"identifierName":"output"}, + "name": "output" + }, + "right": { + "type": "BinaryExpression", + "start":97,"end":109,"loc":{"start":{"line":2,"column":11},"end":{"line":2,"column":23}}, + "left": { + "type": "MemberExpression", + "start":97,"end":104,"loc":{"start":{"line":2,"column":11},"end":{"line":2,"column":18}}, + "object": { + "type": "Identifier", + "start":97,"end":101,"loc":{"start":{"line":2,"column":11},"end":{"line":2,"column":15},"identifierName":"args"}, + "name": "args" + }, + "computed": true, + "property": { + "type": "NumericLiteral", + "start":102,"end":103,"loc":{"start":{"line":2,"column":16},"end":{"line":2,"column":17}}, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + }, + "operator": "+", + "right": { + "type": "NumericLiteral", + "start":107,"end":109,"loc":{"start":{"line":2,"column":21},"end":{"line":2,"column":23}}, + "extra": { + "rawValue": 10, + "raw": "10" + }, + "value": 10 + } + } + } + } + ], + "directives": [] + }, + "alternate": { + "type": "BlockStatement", + "start":118,"end":136,"loc":{"start":{"line":3,"column":7},"end":{"line":5,"column":1}}, + "body": [ + { + "type": "ExpressionStatement", + "start":122,"end":134,"loc":{"start":{"line":4,"column":2},"end":{"line":4,"column":14}}, + "expression": { + "type": "AssignmentExpression", + "start":122,"end":133,"loc":{"start":{"line":4,"column":2},"end":{"line":4,"column":13}}, + "operator": "=", + "left": { + "type": "Identifier", + "start":122,"end":128,"loc":{"start":{"line":4,"column":2},"end":{"line":4,"column":8},"identifierName":"output"}, + "name": "output" + }, + "right": { + "type": "NumericLiteral", + "start":131,"end":133,"loc":{"start":{"line":4,"column":11},"end":{"line":4,"column":13}}, + "extra": { + "rawValue": 20, + "raw": "20" + }, + "value": 20 + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + }, + "comments": [ + { + "type": "CommentBlock", + "value": " istanbul ignore next ", + "start":22,"end":48,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":48}} + } + ] +} \ No newline at end of file diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-arrow-function/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-arrow-function/output.js index fb4695950f6c..5def3730d465 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-arrow-function/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-arrow-function/output.js @@ -2,6 +2,7 @@ var _ref, _ref2, _ref3; const result = (_ref3 = -2.2 // -2.2 , (_ref2 = Math.floor(_ref3) // -3 -, (_ref = () => Math.pow(_ref2, 5), _ref()))); // -243 +, (_ref = () => Math.pow(_ref2, 5) // () => -243 +, _ref()))); // -243 expect(result).toBe(-243); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-in-arrow-function/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-in-arrow-function/output.js index 99d111d1d55e..66106a985d16 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-in-arrow-function/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-in-arrow-function/output.js @@ -3,7 +3,8 @@ const result = () => { return _ref3 = -2.2 // -2.2 , (_ref2 = Math.floor(_ref3) // -3 - , (_ref = () => Math.pow(_ref2, 5), _ref())); + , (_ref = () => Math.pow(_ref2, 5) // () => -243 + , _ref())); }; // -243 diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-arrow-function/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-arrow-function/output.js index fb4695950f6c..5def3730d465 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-arrow-function/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-arrow-function/output.js @@ -2,6 +2,7 @@ var _ref, _ref2, _ref3; const result = (_ref3 = -2.2 // -2.2 , (_ref2 = Math.floor(_ref3) // -3 -, (_ref = () => Math.pow(_ref2, 5), _ref()))); // -243 +, (_ref = () => Math.pow(_ref2, 5) // () => -243 +, _ref()))); // -243 expect(result).toBe(-243); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-in-arrow-function/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-in-arrow-function/output.js index 99d111d1d55e..66106a985d16 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-in-arrow-function/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-in-arrow-function/output.js @@ -3,7 +3,8 @@ const result = () => { return _ref3 = -2.2 // -2.2 , (_ref2 = Math.floor(_ref3) // -3 - , (_ref = () => Math.pow(_ref2, 5), _ref())); + , (_ref = () => Math.pow(_ref2, 5) // () => -243 + , _ref())); }; // -243