0

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?

2
  • I think I have found the answer to my question. See here: stackoverflow.com/a/37899294/536299 Commented Nov 25, 2017 at 18:49
  • Thanks to David Sherret for his reply to the other question. Commented Nov 25, 2017 at 18:58

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.