index signature

A type rule such as { [key: string]: string } for objects whose property names are not known in advance.

In more detail

It fits dictionaries such as HTTP headers, query parameters and metadata. Every explicitly listed property must also fit the index signature's value type. Combine it with noUncheckedIndexedAccess so lookups return value | undefined.

Example

metadata: { [key: string]: string };

Related terms

Taught in

References