I'm encountering an issue while trying to initialize an object based on a TypeScript interface. Even though I am assigning a value, I still receive an error stating that the property is undefined.
interface ITableData {
domainObjectName: string;
domainObjectType: string;
recordId: string;
}
interface IDataMap {
recordId?: string;
controlId?: string;
}
interface IMap {
[key: string]: IDataMap;
}
tableData: ITableData[];
dataMap: IMap;
createDataMap() {
Object.keys(this.tableData).forEach(i => {
const recordId = this.tableData[i].recordId;
this.dataMap[recordId] = {
recordId: recordId,
controlId: ''
};
});
}
After researching and debugging, it appears that TypeScript is flagging the creation of an object key without a value assignment, even though a value is being assigned.
Your assistance would be greatly appreciated.