-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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 mapping of tokens with generated nodes in between #16948
Fix mapping of tokens with generated nodes in between #16948
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/58292 |
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 is very likely the trouble I ran into, though I have not yet isolated. Thank you!
if (child == null) continue; | ||
if (child.start == null || child.end == null) continue; |
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.
if (child == null) continue; | |
if (child.start == null || child.end == null) continue; | |
if (child == null || child.start == null || child.end == null) continue; |
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.
Heheh unfortunately typescript-eslint complains that child == null || child.start == null
should be rewritten to child?.start == null
, but I find child?.start == null || child.end == null
to be terrible so this two-lines solution was the compromise I reached with the linter :P
Whops, wrong commit message 😓 I'll at least rename the PR for the changelog |
I tried to use Before this PR, -__arrayFindLast(/* isOptionalObject */false, foo, callback);
+__arrayFindLast(/* isOptionalObject */false,foo,callback) Space between arguments are removed, comma not printed. After this PR, the output seems getting worse - __at(/* isOptionalObject */true,foo?.bar.baz,-1)
+ __at (/* isOptionalObject */true,foo?.bar.baz,-1) The call expression is generated by this function https://github.com/prettier/prettier/blob/1abee7352fe98f8d484a0e813ebe531fffb8503e/scripts/build/transform/transforms/create-method-call-transform.js#L30 I'm not sure how this works, and not really care about the output that much, but I guess worth to point it out. |
See the first commit to see the wrong output. The problem was that a
null
start was flowing to the binary search, failing both<
and>
comparisons, and thus considering it as "matched" and returning the middle point.cc @kriskowal