Skip to content

Conversation

@Jack-Works
Copy link
Contributor

Before:
image

After:
Only one error with the correct length (but trivia is included, I don't know how to remove it from the error range)
image

With code fix:
image

After code fix:
image

After fix all:
image

@sandersn sandersn added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Apr 21, 2020
Copy link
Member

@andrewbranch andrewbranch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few nits; I think this looks like a big improvement.

if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right)) {
error(left, Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects);
const sf = getSourceFileOfNode(left);
const isInDiag2657 = sf.parseDiagnostics.some(diag => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could consider using forEach or a for/of loop to terminate once diag.start > left.end.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't catch that, Array.some can quite early, I think it is same as for/of + break

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean that with .some, if you don’t find the diagnostic you’re looking for, you’ll keep looking all the way to the end of the array. But since these diagnostics are added in the order that the parser sees them, you know that after you move all the way past the end of left, you’re not going to find what you’re looking for at all. So while .some can terminate early in the positive case, you also have an opportunity to terminate early in the negative case.

That said, I don’t think it’s a big deal since this is an error scenario and the body of the loop isn’t expensive.

@Jack-Works
Copy link
Contributor Author

rebased to resolve conflict

@Jack-Works
Copy link
Contributor Author

rebased to resolve conflict again

Jack-Works and others added 2 commits June 2, 2020 03:03
Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>
Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>
@Jack-Works Jack-Works requested a review from andrewbranch June 1, 2020 19:04
@andrewbranch andrewbranch merged commit 8e290e5 into microsoft:master Jun 1, 2020
cangSDARM added a commit to cangSDARM/TypeScript that referenced this pull request Jun 2, 2020
* upstream/master: (78 commits)
  LEGO: check in for master to temporary branch.
  Skip default when initially iterating exports in __importStar, same as __exportStar (microsoft#38808)
  fix line endings
  Improve error range for ts2657 (jsx expr must have parent element), add code fix for it (microsoft#37917)
  fix(32341): add prefix name for module exports properties (microsoft#38541)
  fix(19385): add space after brace in the multiline string template (microsoft#38742)
  fix(38815): dive in arrow functions to check only this usage instead of checking all statements (microsoft#38865)
  LEGO: check in for master to temporary branch.
  LEGO: check in for master to temporary branch.
  LEGO: check in for master to temporary branch.
  LEGO: check in for master to temporary branch.
  LEGO: check in for master to temporary branch.
  LEGO: check in for master to temporary branch.
  LEGO: check in for master to temporary branch.
  LEGO: check in for master to temporary branch.
  Convert HTML tags in doc-comments into markdown
  fix linting error
  LEGO: check in for master to temporary branch.
  LEGO: check in for master to temporary branch.
  fix(38722): change error message for use-before-declaration on const enum (microsoft#38728)
  ...
@Jack-Works Jack-Works deleted the codefix/jsx-2695 branch February 26, 2021 05:29
@Jack-Works
Copy link
Contributor Author

Is the code fix still woring? I cannot use it in 4.3.0-dev-20210323. Is it removed or a regression?

@andrewbranch
Copy link
Member

I think it must be a regression.

@Jack-Works
Copy link
Contributor Author

I think it must be a regression.

Should I open a new issue for it? Or is there a fix already on the fly?

@andrewbranch
Copy link
Member

You can open a new issue. The weird thing is that tests are of course passing. So some investigation is probably needed.

@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants