microsoft / microsoft/TypeScript

Infinities as number literal types

Aperta
#56,272 6 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

In Discussion Suggestion
Lingua principale
Go
Stelle
111k
Fork
14.4k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

🔎 Search Terms

infinity number literal

🕗 Version & Regression Information
⏯ Playground Link

https://www.typescriptlang.org/play?ts=5.3.0-dev.20231031#code/C4TwDgpgBACg9gZwJbCQNwgSQHYDMnYohQC8UAjBAJw0DcAUAPSNSsB6A-PaJFAHIQA5gENUGHPkKhSUALSUaVBs1ZRO9IA

💻 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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con l’esempio Playground collegato e confronta il comportamento di TypeScript 5.2 con il comportamento imminente di 5.3 introdotto da PR 55268. Esamina la discussione in quella pull request e nell’issue 56270, quindi stabilisci il trattamento previsto dell’infinito positivo e negativo prima di modificare il comportamento del compilatore e la relativa copertura delle regressioni.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
typescript
Ambito
compilers
Tipo di issue
Bug
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.