1

I have the following Typescript code:

export type MyType = {
  stuff1?: {
    [stuff2: string]: Stuff3;
  };
}

What does this mean?

I understand that this is defining a type MyType and it is an object with optional key stuff1. The type of stuff1 is itself an object.

But what does that sub-object look like? I know that sub-object has one key-value pair. And the value of that pair is of type Stuff3. But what does [stuff2: string] mean in this context?

Saqib Ali
  • 11,931
  • 41
  • 133
  • 272

0 Answers0