Skip to content

Commit

Permalink
fix: returnType with comments generates incorrect code (#14758)
Browse files Browse the repository at this point in the history
* fix

* review
  • Loading branch information
liuxingbaoyu committed Jul 14, 2022
1 parent 0df9f62 commit b8f5afd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/babel-generator/src/generators/methods.ts
Expand Up @@ -11,7 +11,15 @@ export function _params(
this._parameters(node.params, node);
this.token(")");

this.print(node.returnType, node);
if (node.returnType) {
if (node.type === "ArrowFunctionExpression") {
this._noLineTerminator = true;
this.print(node.returnType, node);
this._noLineTerminator = false;
} else {
this.print(node.returnType, node);
}
}
}

export function _parameters(
Expand Down
@@ -0,0 +1 @@
export default (): void /* hi! */ => {};
@@ -0,0 +1 @@
export default ((): void /* hi! */ => {});

0 comments on commit b8f5afd

Please sign in to comment.