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: Print multi-line inner comments of arrowFunc #15159
fix: Print multi-line inner comments of arrowFunc #15159
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/53533/ |
this.print(node.returnType, node, node.type === "ArrowFunctionExpression"); | ||
this.print(node.returnType, node); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this is going to be removed, although we no longer wrap comments here.
848d6e6
to
0229ccc
Compare
0229ccc
to
89f704a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like we should just remove this test case.
In this case, the innerComments
are not generated by the parser from a valid JS, instead it is manipulated by the AST transform.
The fact that
(x, y) /* line break here
*/ => {}
is invalid implies that the transformed AST is invalid. Babel generator should not guarantee that it work with an invalid AST. In this case, I think it is fine to do nothing and just remove this test case. The generator may generate invalid JS if the AST is invalid.
This test has nothing to do with this PR, this is a regression test, in #15160 (comment) we decided to never generate invalid code due to invalid comments. |
As is mentioned there, #15160 conflicts with this PR. The #15160 ensures that the generator prints valid code in It seems to me this PR "more specifically" supports multi-line inner comments in the [NLTH] position of the arrow function
|
My personal preference is that we don't guarantee it but if someone wants to do it or if someone opens an issue about it we will accept it. Also this should restore the previous behavior where it was printed as inner comments a few PRs ago. |
Fixes #1, Fixes #2