Skip to content

Commit

Permalink
Don't print inner comments as leading when wrapping in () (#15143)
Browse files Browse the repository at this point in the history
* Don't print inner comments as leading when wrapping in `(``)`

* Fix if there is a previous token
  • Loading branch information
nicolo-ribaudo committed Nov 10, 2022
1 parent 9862d42 commit 64c03d6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/babel-generator/src/printer.ts
Expand Up @@ -637,7 +637,10 @@ class Printer {
} else {
shouldPrintParens = needsParens(node, parent, this._printStack);
}
if (shouldPrintParens) this.token("(");
if (shouldPrintParens) {
this.token("(");
this._endsWithInnerRaw = false;
}

this._lastCommentLine = 0;

Expand Down
@@ -0,0 +1,3 @@
1 + ((/* c */) => {});

(function /* c */ () {});
@@ -0,0 +1,2 @@
1 + (( /* c */) => {});
(function /* c */ () {});

0 comments on commit 64c03d6

Please sign in to comment.