Microsoft/TypeScript
GitHub ã§èŠãerror in Variadic Tuple Types , if i reverse the partial function
Open
#56,970 opened on 2024幎1æ7æ¥
Domain: check: Type InferenceHelp WantedPossible Improvement
Repository metrics
- Stars
- Â (48,455 stars)
- PR merge metrics
-  (å¹³åããŒãž 6d 17h) (30d ã§ 9 merged PRs)
説æ
ð 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