Skip to content
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(46195): handle numeric separators and larger integers correctly in codefix for large integers #46389

Merged
merged 2 commits into from
Dec 3, 2021

Conversation

lowr
Copy link
Contributor

@lowr lowr commented Oct 15, 2021

Fixes #46195

This PR fixes 2 bugs, one of which I found while fixing the other:

  • numeric separators are not handled (Lint warning "ts(80008)" ignoring numeric separators #46195)
  • suggestions are not shown for larger integers (playground)
    • this is caused by misuse of node.text, which is not the textual representation of the literal in the source code, but toString() representation of the number (explained here)
    • e.g. node.text for numeric literal 1100000000000000000000 is 1.1e21, which has been bypassing the check due to the predicate node.text.length <= 15.

Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

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

The idea seems sound. I'd like to see a few more compiler tests.

@sandersn sandersn merged commit bedc8d4 into microsoft:main Dec 3, 2021
mprobst pushed a commit to mprobst/TypeScript that referenced this pull request Jan 10, 2022
…n codefix for large integers (microsoft#46389)

* fix(46195): handle numeric separators and larger integers correctly

* Use `indexOf()` instead of `includes()`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Lint warning "ts(80008)" ignoring numeric separators
3 participants