Microsoft/TypeScript
Vedi su GitHub'Any' on anonymous function argument response in generic
Open
#47.858 aperta il 12 feb 2022
BugDomain: check: Type InferenceHelp Wanted
Metriche repository
- Star
- (48.455 star)
- Metriche merge PR
- (Merge medio 6g 17h) (9 PR mergiate in 30 g)
Descrizione
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.