Microsoft/TypeScript
在 GitHub 查看'Any' on anonymous function argument response in generic
Open
#47,858 创建于 2022年2月12日
BugDomain: check: Type InferenceHelp Wanted
仓库指标
- Star
- (48,455 star)
- PR 合并指标
- (平均合并 6天 17小时) (30 天内合并 9 个 PR)
描述
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.