Manuel Schiller Manuel Schiller - 1 year ago 298
TypeScript Question

Interface for dynamic key in typescript

I have an Object like this that is created by underscore's


myObject = {
"key" : [{Object},{Object2},{Object3}],
"key2" : [{Object4},{Object5},{Object6}],

How would I define that as an Interface with TypeScript?
i don't want to simply define it as
myObject:Object = { ...
but rather have an own type for it.

Answer Source

Your object looks like a dictionary of Object arrays

interface Dic {
    [key: string]: Object[]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download