I see the TypeScript handbook, in the Advanced Types section, it has code like this:
interface Dictionary<T> {
[key: string]: T;
}
let keys: keyof Dictionary<number>; // string | number
let value: Dictionary<number>['foo']; // number
I can't understand the ['foo']
, if it just declare that the index is string
?
hmm, i find that ['foo'] certainy not limit the var must be the value of key 'foo' of a dictionary, and the follow statements is equivalent:
let value: Dictionary<number>['foo'];
let value: Dictionary<number>['abc'];
let value: Dictionary<number>[string];
is it right?