3👍
✅
You have declared your ReceivedChart
as an empty array and thus have given it the type any[]
.
this.ReceivedChart = []; // TypeScript infers the type to be any[] here
In your code you are creating a new chart and setting it to this variable.
this.ReceivedChart = new Chart(...);
TypeScript is complaining because you are setting a Chart
object to what it is expecting to be an array. You will either need to set up your variable to be of type Chart
(which you are attempting to set it to) or you will need to push the chart you just created onto your array.
this.ReceivedChart.push(new Chart(...));
Source:stackexchange.com