I have an array of objects like below defined in my interface:
myArray: [{
id: number;
item: string;
checked: boolean;
}]
I am trying to clone the array using the below statement:
let newArray = myArray.map(x => Object.assign({},x));
When I am trying to assign a new array to my original array, I am getting the below error:
Type '{ id: number; item: string; checked: boolean; }[]' is not assignable to type
'[{ id: number; item: string; checked: boolean; }]'.
Target requires 1 element(s) but source may have fewer
It looks like the array of objects is being transformed to an object of array.