How to define an interface for objects with dynamic keys?

Your object looks like a dictionary of Object arrays

interface Dic {
    [key: string]: Object[]
}

The typescript literature often refers to this pattern as “the description of an indexable object” with a general form

interface Dic {
    [key: string|number]: object_type
}

or

type Dic = {
    [key: string|number]: object_type
}

Leave a Comment