Imagine you're trying to implement this method in Typescript:
setResult(guId: string,fieldname: string, data:Array<UsedTsoClusterKey>) {
let octdctruns: OctDctRun[] = [...this.octDctRuns];
const index = octdctruns.findIndex((o) => o.guid === guId);
octdctruns[index][fieldname] = data;
this.octDctRuns = octdctruns;
}
The structures UsedTsoClusterKey and OctDctRun are defined as follows:
export interface UsedTsoClusterKey {
runGUID: string;
tsoClusterKeyID: string;
tsoClusterKeyVersion: string;
validFrom: DateString;
validUntil: DateString;
}
export interface OctDctRun {
guid: string;
moduleType: string;
runTime: DateString;
calcIntervalFrom: DateString;
calcIntervalUntil: DateString;
triggerType: string;
triggerID: string;
usedTSOClusterKeys: UsedTsoClusterKey[];
}
However, an error is occurring at the line octdctruns[index][fieldname] = data:
Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'OctDctRun'.
No index signature with a parameter of type 'string' was found on type 'OctDctRun'
If anyone could shed some light on what's going wrong here, it would be greatly appreciated!