Index signature is missing in type (only on interfaces, not on type alias)
TypeScript Version: 2.2.2
Code
interface IndexType { [key: string]: string; } interface doesNotWork { hola: string; } type doWorks = { hola: string }; let y: IndexType; const correctA = { hola: "hello" }; const correctB: doWorks = { hola: "hello" }; //error should be assignable to y const error: doesNotWork = { hola: "hello " }; y = correctA; y = correctB; y = error; //Index signature is missing in type 'doesNotWork' y = {... error}; //workaround but not equivalent since the instance is not the same
Expected behavior:
The code should not result on a compiler error since the interface doesNotWork is equivalent to the type { hola: string }
Actual behavior:
Variable error of type doesNotWork can't be assigned to y