Microsoft/TypeScript
View on GitHub'Any' on anonymous function argument response in generic
Open
#47,858 opened on Feb 12, 2022
BugDomain: check: Type InferenceHelp Wanted
Repository metrics
- Stars
- (48,455 stars)
- PR merge metrics
- (Avg merge 6d 17h) (9 merged PRs in 30d)
Description
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.