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.
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
Under jsx: preserve, actually preserve expressions which contain only comments #41757
Under jsx: preserve, actually preserve expressions which contain only comments #41757
Changes from 1 commit
b35a401
d1db247
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
hasCommentAtPosition
isn't a thing we currently have, but this does a, okay job of approximating it. Obviously doesn't handle something likeMaybe it's worth doing a full check with
forEachTrailingCommentRange
? @rbuckton - your opinion?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.
do we care about
//
comments? The new check only handles/**/
comments, right?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.
Yep. That's why I'm asking if it's worth doing a full comment range iteration to check if there are any comments attached to the position.
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.
This change (and the similar ones in
system
) are what fix the crash mentioned in the OP. The non-module file has a reference to a synthetic import that, since it's never actually inserted into the file (since it's not a module), is never parented, and thus has no name. We emit a (admittedly type system, rather than grammar/program) error in these cases usually (module "react/jsx-runtime" not found
), so the emitted JS being nonfunctional is probably fine, but this case might need a more descriptive error added. The emit simply uses an arbitrary name now (_a
), rather than crashing.Since this part fixes a crash, I'm wondering if I should (partially?) port this to the 4.1 branch or no? @DanielRosenwasser ?
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.
This comment may actually be referring to the crash fixed here (assuming the input file is exactly what the user in that comment says, odd as a top-level
return
is, since we wouldn't mark that as a module), though the stack is very different than the on the OP of that thread refers to (and is definitely a separate issue).