Reputation: 24709
I am in reference to the typescript documentation about advanced types. See here.
The following example is given:
interface Map<T> {
[key: string]: T;
}
I understand the Map's type variable T.
My doubt is rather about the syntax within the interface declaration i.e. this exact line:
[key: string]: T;
Can someone please translate in english what the above line means?
And refer me to relevant documentation about the square brackets syntax for the key?
Upvotes: 0
Views: 44
Reputation: 24709
I have found the answer to my question. It is a Typescript Index Signature.
See following link for a comprehensive explanation: https://basarat.gitbooks.io/typescript/docs/types/index-signatures.html
Upvotes: 1