I have a Typescript interface that is just a set of fields, e.g.
export interface Data {
date_created: string;
stamp: string;
}
let myData: Data;
However, my case requires me to add "dynamic" fields that I can not hard-code before runtime, so I should be write something like
const dynamicFieldname = getDynamicFieldNameFromSomeDataSource(); // type is string.
mydata[dynamicFieldname] = dynamicFieldvalue;
when I write this, I get a Typescript Error:
Error: TS7017: Element implicitly has an 'any' type because type 'Data' has no index signature.
How can I achieve the possibility to have these dynamic fields in my Typescript object, such as, how can I add the required 'index signature' to an interface?