Fix printing of comments before =>#15160
Conversation
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/53392/ |
|
This PR looks good to me, can we keep https://github.com/babel/babel/pull/15159/files#diff-6c32c344bfe1f4e77de24cdd3e427e84c4ac0a871380ff3720a7351cac63cb74R197-R198? |
This comment was marked as outdated.
This comment was marked as outdated.
|
Well, we could still keep the new |
|
The current Also the output in #15161 is weird, it seems like we are wrapping comments for non-existent, it might be worth me to open a PR to optimize. |
It's automatically set to false after printing a token/word. [no LineTerminator here] is only between two tokens, so after printing the second one is always safe to set |
This fix conflicts with the fix proposed in #15159, however I believe that it solves the problem in a better way: we must keep the correct
_noLineTerminatorto make sure to disallow any multiline comment right before=>.All these cases with multi-line comments before
=>cannot happen just by parsing+printing the source code, but can happen if plugins modify the AST. It's better to miss printing the comment (or to report an error, as in #15158), but we should never generate invalid code.