I am trying to have a Typescript interface which allows dynamic keys in combination with further data, that is not dynamic. But it seems as though whenever I declare dynamic keys - is this possible at all?
export interface Templates {
[key: string]: Template;
reportSource: string;
}
above code results in:
Property 'reportSource' of type 'string' is not assignable to string index type 'Template'.ts(2411)
This compiles, but is quite suboptimal, because now every key can be either of type Template or string, while I am trying to achieve that only reportSource can be of type string and all other keys are of type Template.
export interface Templates {
[key: string]: Template | string;
reportSource: string;
}