microsoft / microsoft/TypeScript
Rest tuple parameter with intersection/union places error on wrong argument
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.4k
- Merge medio
- 1 d 19 h
- PR fusionados (30 d)
- 117
Descripción
TypeScript Version: 3.2.0-dev.20181113
Search Terms:
rest tuple, intersection, union, error, argument, misplaced
Code
declare function boop<T extends any[]>(...args: T & [number, string]): void;
boop(123, 456); // error
// ~~~ <-- error on first argument
// Argument of type '[123, 456]' is not assignable to parameter
// of type '[number, number] & [number, string]'.
// Type '[123, 456]' is not assignable to type '[number, string]'.
// Type '456' is not assignable to type 'string'.
Expected behavior:
I expect an error on the second argument (456), since that's the argument that causes the failure, as made evident by the error message. (Or possibly I expect an error on both arguments, if it's interpreted as a failure to match the rest parameter.)
Actual behavior:
The actual error is on the first argument (123). This is a minor problem, and it only seems to show up in the intersection-with-type-parameter situation above (concrete types like ...args: [number, string] & [number, string] work fine), but I figured I'd report it in case it has an easy fix.
(Note to self or interested non-selves: ran into this in a Stack Overflow answer)
Playground Link:
🔗
Related Issues:
Haven't found anything. Anyone find anything?
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
Comience con la reproducción proporcionada en TypeScript Playground y compare el intervalo de diagnóstico reportado con el argumento que se espera que falle. Siga cómo el compilador gestiona los parámetros de tupla rest combinados con una intersección de parámetros de tipo y, después, verifique que el diagnóstico apunte al segundo argumento sin introducir una regresión en el caso de intersección concreta.
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
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100