Fix missing inner comments in function expressions#13825
Merged
nicolo-ribaudo merged 2 commits intobabel:mainfrom Oct 7, 2021
Merged
Fix missing inner comments in function expressions#13825nicolo-ribaudo merged 2 commits intobabel:mainfrom
nicolo-ribaudo merged 2 commits intobabel:mainfrom
Conversation
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit d86b098:
|
fedeci
approved these changes
Oct 7, 2021
JLHwung
reviewed
Oct 7, 2021
| const f = function /*foo*/ () {}; | ||
| const g = async function /*foo*/ () {}; | ||
| const h = function* /*foo*/ () {}; | ||
| const i = async function* /*foo*/ () {}; |
Contributor
There was a problem hiding this comment.
Can you add a new test case?
const j = function (/*foo*/) {};
it will be printed as
const j = function /*foo*/ () {};
I think we don't have to fix that. It is the nature of using AST for comment attachment targets.
Contributor
Author
There was a problem hiding this comment.
Have pushed another commit adding this case.
I also added cases for other positions of comments in async + generator functions.
const x = async /*foo*/ function () {};
const y = function/*foo*/* () {};Similarly, these don't come out quite the same as the input, but at least the comment isn't omitted entirely now.
JLHwung
approved these changes
Oct 7, 2021
JLHwung
approved these changes
Oct 7, 2021
existentialism
approved these changes
Oct 7, 2021
Member
|
The CI failures seem to be caused by the npm outage. |
Contributor
Author
|
Thanks all! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Same as #13824 but for function expressions.
Similar to #13819, function expressions with inner comments do not have the comments output by
generate(). This PR fixes that.For async functions, there's some ambiguity as to where the comment should be output i.e.:
or:
I have gone for the latter as for single line comments, putting the comment after
asyncis invalid JS. This is not valid:whereas this is: