Hey there! I'm currently working on an Angular project and encountering an error in my VS Code. I'm a bit stuck on how to fix it.
Type 'IterableIterator<any>' is not an array type or a string type.
Use compiler option '--downlevelIteration' to allow iterating of iterators.ts(2569)
Below is the snippet of the code causing the issue:
aggregator(data: HistogramDistribution[]) {
data.forEach(
item => {
item.dateRange = moment.utc(item.dateRange).local().format("YYYY-MM-DD").toString();
}
);
return [...data
.reduce((acc, o) => {
const key = o.dateRange,
group = acc.get(key)
group ?
(group.total += o.total,
group.delivered += o.delivered,
group.undeliverable += o.undeliverable,
group.expired += o.expired,
group.enroute += o.enroute) :
acc.set(key, {...o, dateRange: key})
return acc
}, new Map)
.values()
];
}
I've attempted adding "downlevelIteration": true to my tsconfig.json but the error persists.
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": ["node_modules/@types"],
"lib": ["es2017", "dom"],
"downlevelIteration": true
}
}
Would really appreciate any assistance you can provide.
Thank you!