Microsoft/TypeScript
Voir sur GitHub'Any' on anonymous function argument response in generic
Open
#47 858 ouverte le 12 févr. 2022
BugDomain: check: Type InferenceHelp Wanted
Métriques du dépôt
- Stars
- (48 455 stars)
- Métriques de merge PR
- (Merge moyen 6j 17h) (9 PRs mergées en 30 j)
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.