TypeScript Version: 3.1.0-dev.20180823
Code
interface Idx {
[key: string]: number;
}
interface Obj {
idx?: Idx;
}
const l: Obj = {};
l.idx = {}; // Works
interface Fn {
(): void;
idx?: Idx;
}
const fn: Fn = () => {}; // Error: `{}` not assignable to `Idx`
fn.idx = {};
Expected behavior:
No error.
Actual behavior:
src/a.ts:15:7 - error TS2322: Type '{ (): void; idx: {}; }' is not assignable to type 'Fn'.
Types of property 'idx' are incompatible.
Type '{}' is not assignable to type 'Idx'.
Index signature is missing in type '{}'.
Discovered in koa-morgan on DefinitelyTyped. Probably due to #26368.