Having this interface declaration :
interface Thing1 {
[key: string]: string;
x: number;
}
Typescript, while compiling, throws an error "TS2411: Property 'x' of type number is not assignable to string index type 'string'"
It sounds legit.
However, as soon as I use an object literal as my indexed type value :
interface Foo {}
interface Thing2 {
[key: string]: Foo;
foo: number;
}
... it doesn't complain anymore, which sounds weird to me as number
is still a different type than Foo
Any idea on the reason behind this ?
Note: Using Typescript 2.1.5