Closed
Description
TypeScript Version: 3.1.0-dev.201xxxxx
Search Terms:
function parameter type inference keyof generic
Code
function foo1<T>(foo: T, bar: {[key in keyof {foo: number}] : (x: T) => number }) {
}
function foo2<T>(foo: T, bar: {[key in keyof T] : (x: T) => number }) {
}
foo1({foo: 1}, {foo: x1 => x1.foo + 1})
foo2({foo: 1}, {foo: x2 => x2.foo + 1})
Expected behavior:
x2
has type {foo:number}
Actual behavior:
Compiler error
TS7006: Parameter 'x2' implicitly has an 'any' type.
x1
has type {foo:number}
but
x2
has type any
Playground Link:
Playground