Skip to content

Latest commit

 

History

History
30 lines (23 loc) · 610 Bytes

20210819100328-index_signature.org

File metadata and controls

30 lines (23 loc) · 610 Bytes

Index signature

See also Constants, interfaces and types

Basic usage

The name of the next (eg, id, key) is arbitrary.

interface Foo {
  [id: number]: string;
  [key: string]: string;
}

Using a set of literals

type FooKey = 'a' | 'b' | 'c'

type Foo {
  [key in FooKey]: string
}