I am reading through official doc and there is one example code to describe string vs number index type. But I don't quiet get why this is marked as error in TS.
The following line [x: number]: Animal; in the below code.
interface Animal {
name: string;
}
interface Dog extends Animal {
breed: string;
}
// Error: indexing with a numeric string might get you a completely separate type of Animal!
interface NotOkay {
[x: number]: Animal;
'number' index type 'Animal' is not assignable to 'string' index type 'Dog'.
[x: string]: Dog;
}
