Microsoft/TypeScript
GitHub ã§èŠã'Any' on anonymous function argument response in generic
Open
#47,858 opened on 2022幎2æ12æ¥
BugDomain: check: Type InferenceHelp Wanted
Repository metrics
- Stars
- Â (48,455 stars)
- PR merge metrics
-  (å¹³åããŒãž 6d 17h) (30d ã§ 9 merged PRs)
説æ
Bug Report
ð Search Terms
- Anonymous function response
ð Version & Regression Information
4.5 and below
⯠Playground Link
Simplified:
Actual:
ð» Code
function transform<O extends { [key: string]: (...args: any[]) => (arg: number) => void }>(input: O) {
}
transform({
fn1: (input: string) => (data) => {
},
f2: (input: string) => {
return (data) => { // coming back as any instead of number
}
},
fn3(input: string) {
return (data) => {
}
},
})
ð Actual behavior
The generic argument in the return function is coming back as any instead of number when it's returned as an anonymous inline function.
ð Expected behavior
Expecting the inline anonymous function response to be of type number.