Microsoft/TypeScript
GitHub ã§èŠãAnnotated parameters are not used for inferring rest parameters
Open
#58,746 opened on 2024幎6æ3æ¥
Domain: check: Type InferenceHelp WantedPossible Improvement
Repository metrics
- Stars
- Â (48,455 stars)
- PR merge metrics
-  (å¹³åããŒãž 6d 17h) (30d ã§ 9 merged PRs)
説æ
ð Search Terms
annotated, "rest parameter"
ð Version & Regression Information
- This is the behavior in every version I tried
⯠Playground Link
ð» Code
function mkAction<Input extends any[]>(action: {
f1:(...xs:Input) => void,
f2:(...xs:Input) => void,
}) {}
mkAction({
f1(x:string, y:number) {},
f2(x, y) {},
// x and y are inferred as "any",
// even though f2 is inferred as "(x: string, y: number) => void"
});
ð Actual behavior
Arguments "x" and "y" are inferred as "any", even though "f2" has the correct type (x: string, y: number) => void
ð Expected behavior
I would expect inference of x: string and y: number for the arguments of "f2".
Additional information about the issue
No response