Closed
Description
TypeScript Version: master
Search Terms:
Code
declare function f<T extends object>(data: T, handlers: { [P in keyof T]: (value: T[P], prop: P) => void; }): void;
f({ data: 0 }, {
data(value, key) {
},
});
Should also work with optional.
declare function f<T extends object>(data: T, handlers: { [P in keyof T]?: (value: T[P], prop: P) => void; }): void;
f({ data: 0 }, {
data(value, key) {
},
});
Expected behavior:
pass
Actual behavior:
$ node built/local/tsc.js --strictNullChecks --noImplicitAny index.ts
index.ts:3:8 - error TS7006: Parameter 'value' implicitly has an 'any' type.
3 data(value, key) {
~~~~~
index.ts:3:15 - error TS7006: Parameter 'key' implicitly has an 'any' type.
3 data(value, key) {
~~~
Playground Link:
Related Issues: