I have the following interfaces:
export interface Meta {
counter: number;
limit: number;
offset: number;
total: number;
}
export interface Api
You can use an intersection of two interfaces:
interface Api {
[key: string]: T[];
}
type ApiType = Api & {
meta: Meta;
}
declare let x: ApiType;
let a = x.meta // type of `a` is `Meta`
let b = x["meta"]; // type of `b` is `Meta`
let p = x["someotherindex"] // type of `p` is `string[]`
let q = x.someotherindex // type of `q` is `string[]`