microsoft / microsoft/TypeScript

Infinities as number literal types

Abierto
#56,272 6 comentarios 1 reacción 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

In Discussion Suggestion
Lenguaje dominante
Go
Estrellas
111k
Forks
14.4k
Merge medio
1 d 19 h
PR fusionados (30 d)
117

Descripción

🔎 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

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza con el ejemplo de Playground enlazado y compara el comportamiento de TypeScript 5.2 con el próximo comportamiento de 5.3 introducido por PR 55268. Revisa la discusión en ese pull request y en el issue 56270, y determina después el tratamiento previsto de la infinitud positiva y negativa antes de cambiar el comportamiento del compilador y su cobertura de regresión.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
typescript
Área
compilers
Tipo de issue
Error
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.