During a lesson:
private items: Map<number, string> = new Map();
...
this.items[aNumber] = "hello";
Results in this error message:
An element has an
any
type because the expression of typenumber
cannot be used to index typeMap<number, string>
.No index signature with a parameter of type
number
was found on the typeMap<number, string>
I am confused by this. Why doesn't Map<number, string>
have an index signature that includes a parameter of type number
?