How to express an interface (IResponse), with one property has a string key (which is not known statically). Below, the key values can be anything like bo
If you define one interface for the known types and a separate one for the "unknown" types, you could use a type assertion to tell the compiler the one you wanted to use.
It isn't ideal, but you are working in a edge case (i.e. not entirely dynamic, not entirely static).
export interface IMeta{}
export interface IValue{}
export interface IFunkyResponse {
[index: string]:IValue[];
}
export interface IResponse {
meta: IMeta;
}
export class Response implements IResponse {
meta:IMeta;
values:IValue[];
books:IValue[];
anything:IValue[];
}
You can type-assert between and to access one or the other of the styles.