microsoft/TypeScript-Handbook

Document incompatibility between normal interface and indexable type interfaces

geoffreyyip opened this issue · 0 comments

The Person interface cannot be assigned to the Dict interface. According to microsoft/TypeScript#15300, this is intended behavior

However, it is not intuitive behavior and should be documented. The Indexable Interfaces section in the Interfaces page seems like a good place.

interface Dict {
  [index: string]: string;
}

interface Person {
  name: string;
  age: number;
}

const person: Person = { name: "Brendan Elrich", age: 57 };

let y: Dict 
y = person; // error: Index signature is missing in type