strange issue, I get the above mentioned error and I can't figure out why, here's a screenshot showing everything:
Here's my code:
const createSeries = (report: ReportEntry[], key: string) => {
const reportEntryValues: any = [];
let itemColor: string;
let series: ApexAxisChartSeries;
report.forEach((item: ReportEntry) => {
reportEntryValues.push(item[key as keyof typeof item]);
});
switch (key) {
case "approved":
itemColor = Colors.Green;
break;
case "denied":
itemColor = Colors.Red;
break;
default:
itemColor = Colors.Blue;
}
series = {
name: key,
type: "bar",
color: itemColor,
data: reportEntryValues,
};
return series
};
any help is hugely appreciated, I've been googling why this happens, the code works just fine but typescript is still screaming at me.
Thanks in advance!
EDIT: playground link
CodePudding user response:
The problem is that ApexAxisChartSeries
is an Array type. So you ether need to change the ApexAxisChartSeries
to be an Object or return an array.