ashish singh
ashish singh

Reputation: 6904

How to understand typescript index signature?

if I have a type like this

{[index: string]: number}

this means that keys for my object can be string and value will be number.

I wanted to know if this word index has any significance eg, is there a difference between the following two types

{[index: string]: number}

and

{[key: string]: number}

It will be great if some reference can be provided from docs.

Upvotes: 2

Views: 123

Answers (1)

Swanand
Swanand

Reputation: 103

No, index is just a name that is assigned to indicate the index. Practically both the types are same.

Upvotes: 2

Related Questions