I'm currently attempting to search for an element within one array and then assign it to another array object.
However, I keep receiving the following error message:
Type 'ClosureSummary | undefined' is not assignable to type 'ClosureSummary'
var dt = $('#tbl_summary').DataTable();
let ids:string[]=[];
dt.rows({ page: 'current' }).nodes().each(function(item,index){
ids.push(item.id)
});
console.info(ids);
this.liveBoundSummary.forEach(element=>{
let pcode:string=element.ProjectCode;
if(ids.includes(pcode)){
let csItem:any;
element=this.clSummary.find(x=>x.ProjectCode==pcode);
}
});
When trying to insert values from the clSummary array into liveBoundSummary elements, I encounter the undefined error mentioned above.
It's important to note that both clSummary and liveBoundSummary are of the same type, ClosureSummary[].
Can someone provide guidance on how to resolve this issue?