microsoft / microsoft/TypeScript
Infinities as number literal types
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
🔎 Search Terms
infinity number literal
🕗 Version & Regression Information
- This changed in PR https://github.com/microsoft/TypeScript/pull/55268
⏯ Playground Link
💻 Code
type PositiveInfinity = 1e999;
// ^?
type NegativeInfinity = -1e999;
// ^?
🙁 Actual behavior
In TS 5.2 we get NumberLiteralTypes with Infinity and -Infinity values.
In the upcoming TS 5.3 we get a number type in the of the PositiveInfinity
🙂 Expected behavior
I don't know. I created this issue to discuss exactly that.
Should this part of the change be reverted and should Infinity be allowed as a literal number value? Or should -Infinity be aligned with Infinity and should it be converted~ to a number type as well?
Additional information about the issue
I didn't see an Infinity as a literal type so I made this change while working in this area. @rbuckton commented here:
I really hope no one is relying on this.
but it turns out that some try to rely on this. We can see it in this issue, cc @Max10240
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked Playground example and compare the TypeScript 5.2 behavior with the upcoming 5.3 behavior introduced by PR 55268. Review the discussion in that pull request and issue 56270, then establish the intended treatment of positive and negative infinity before changing the compiler behavior and its regression coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100