![](/img/trans.png)
[英]Flow Type error: property of unknown type. This type is incompatible with array type
[英]Typscript error happening . Type 'IterableIterator<any>' is not an array type or a string type.)
嗨,我有一個 angular 項目,我有一個錯誤,我可以在 vss 代碼中看到。 不知道我該如何解決這個問題。
Type 'IterableIterator<any>' is not an array type or a string type.
Use compiler option '--downlevelIteration' to allow iterating of iterators.ts(2569)
這是代碼片段
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()
];
}
我試圖在我的 tsconfig.json 中添加“downlevelIteration”:true。 但錯誤仍然存在。
{
"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
}
}
感謝您是否可以提供一些幫助。
謝謝你
在tsconfig.json
文件中將編譯目標更改為es6
或更高版本將修復它
{
"compilerOptions": {
"target": "es2015"
}
}
或者如果你想繼續使用舊版本,你可以像這樣啟用downLevelIteration
{
"compilerOptions": {
"target": "es2015",
"downlevelIteration": true
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.