Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: returnType with comments generates incorrect code #14758

Merged
merged 2 commits into from Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we set _noLineTerminator only when node is an ArrowFunctionExpression?

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! */ => {});