0

I'm new to Typescript. I saw the following code in one project on GitHub, What does it mean?

interface info {
  [index: string]: any;
}
AR Second
  • 582
  • 1
  • 6
  • 25
  • 2
    You are looking for [indexable types](https://stackoverflow.com/questions/65114590/what-are-indexable-types-in-typescript). – 109149 Jan 08 '21 at 20:00
  • 2
    Does this answer your question? [What are indexable types in typescript?](https://stackoverflow.com/questions/65114590/what-are-indexable-types-in-typescript) – 109149 Jan 08 '21 at 20:00

1 Answers1

1

It means an Object Literal (An object that is created using curly brackets and can be defined by using type or interface, take a look at this link) that accepts as pairs index: value of type string:any. Eg:

let example: info= {
  index1: "some index",
  index2: 1,
  // ...
};
Fahima Mokhtari
  • 1,691
  • 2
  • 16
  • 30