microsoft / microsoft/TypeScript
When the initial element of the tuple is a rest element, it is not possible to correctly infer the type of the initial element.
Abierto
Nadie ha tomado este issue todavía.
Awaiting More Feedback
Suggestion
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.4k
- Merge medio
- 1 d 19 h
- PR fusionados (30 d)
- 117
Descripción
🔍 Search Terms
initial element of the tuple is a rest element
✅ Viability Checklist
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This isn't a request to add a new utility type: https://github.com/microsoft/TypeScript/wiki/No-New-Utility-Types
- This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
⭐ Suggestion
type T1 = [...string[], number, boolean]
declare const head: T1[0]
// Actual: string | number | boolean
// Expected: string | number
📃 Motivating Example
💻 Use Cases
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza con el ejemplo mínimo de tipo tupla del issue y sigue cómo el comprobador de TypeScript resuelve el acceso indexado T1[0] cuando la tupla comienza con un elemento rest. Se considera terminado cuando el tipo inferido es string | number en lugar de string | number | boolean, y las pruebas existentes del comprobador de tipos se han ampliado para cubrir este caso.
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
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100