microsoft / microsoft/TypeScript
error in Variadic Tuple Types , if i reverse the partial function
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
🔎 Search Terms
Type '[...any[], number]' is not assignable to type '[a: number, b: number, c: number]'.
Target requires 3 element(s) but source may have fewer.ts(2345)
🕗 Version & Regression Information
- This is a crash
- This changed between versions 4.23____ and nightly_
- This changed in commit or PR _______
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about it___
- I was unable to test this on prior versions because _______
⏯ Playground Link
💻 Code
// minimal reproduce
type Arr = readonly any[]
function partialCall<T extends Arr, U extends Arr, R>(
f: (...args: [...T, ...U]) => R,
...headArgs: T
) {
return (...tailArgs: U) => f(...headArgs, ...tailArgs)
}
function partialCallRev<T extends Arr, U extends Arr, R>(
f: (...args: [...U, ...T]) => R,
...tailArgs: T
) {
return (...headArgs: U) => f(...headArgs, ...tailArgs)
}
type l = number
function te(a: l, b: l, c: l): number {
return a + b + c
}
const a = partialCall(te, 1)
const b = partialCallRev(te, 1)// error
🙁 Actual behavior
When I changed the order of parameters in the partialCall function, what I meant was that I wanted to first store the trailing parameters, but an error occurred.
🙂 Expected behavior
i expected it work
Additional information about the issue
No response
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 TypeScript Playground enlazado y la reproducción mínima de partialCallRev, comparándola con la versión funcional de partialCall. Investiga la inferencia de tipos de tuplas variádicas para el orden de parámetros invertido; se considera terminado cuando la forma con parámetros finales pasa la comprobación de tipos para la función mostrada de tres argumentos sin debilitar los tipos de argumentos esperados.
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