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 books
, chairs
, etc. All other keys and types are known statically. Below implementation gives error. I guess the error is because the index signature on the IResponse
makes all the property values to be IValue[]
. Is there a way to do this?
export interface IMeta{}
export interface IValue{}
export interface IResponse {
meta: IMeta;
[index: string]:IValue[];
}
export class Response implements IResponse {
meta:IMeta;
values:IValue[];
//books:IValue[];
//anything:IValue[];
}