Microsoft/TypeScript
'Any' on anonymous function argument response in generic
Offen
#47.858 geöffnet am 12.02.2022
BugDomain: check: Type InferenceHelp Wanted
Repository-Metriken
- Stars
- (108.860 Sterne)
- PR-Merge-Metriken
- (PR-Metriken ausstehend)
Beschreibung
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.