TypeScript Version: 3.1.0-dev.201xxxxx
Search Terms:
function parameter type inference keyof generic
Code
functionfoo1<T>(foo: T,bar: {[keyinkeyof{foo: number}] : (x: T)=>number}){}functionfoo2<T>(foo: T,bar: {[keyinkeyofT] : (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
TypeScript Version: 3.1.0-dev.201xxxxx
Search Terms:
function parameter type inference keyof generic
Code
Expected behavior:
x2has type{foo:number}Actual behavior:
Compiler error
TS7006: Parameter 'x2' implicitly has an 'any' type.x1has type{foo:number}but
x2has typeanyPlayground Link:
Playground