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: Unexpected duplication of comments #16110

Merged
merged 3 commits into from
Nov 22, 2023
Merged
Changes from 1 commit
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
20 changes: 20 additions & 0 deletions packages/babel-generator/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1492,6 +1492,26 @@ describe("programmatic generation", function () {
val
);`);
});

it("multi-line leading comment after return 2", () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

This test has nothing to do with this PR, it just ensures that #16104 does not cause regressions.

const ast = parse(
`return (
/*new
line*/ val);`,
{
allowReturnOutsideFunction: true,
},
);
// Remove `parenthesized`
ast.program.body[0].argument.extra = null;
expect(generate(ast).code).toMatchInlineSnapshot(`
"return (
/*new
line*/
val
);"
`);
});
});
});

Expand Down