I am using ionic 4 to build an app. Whereas my app is working fine on browser but when I build android platform it is giving me error for this line
for (let [index, p] of this.cart.entries())
My typescript version is 3.7.2
The error is
Type 'IterableIterator<[number, any]>' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators.
I solved it by adding "downlevelIteration": true, in compilerOptions inside tsconfig.josn file. Note my target was es2015
I had similar issue following was the map and loop ended up in error
public lastviewed = new Map<string, object>();
for (const [key, value] of this.lastviewed.entries()) { //didnt work
console.log(" Key : ", key, " Val : ", value);
}
resulted in Error : Type 'IterableIterator<[string, object]>' is not an array type or a string type. Use compiler option '--downlevelIteration' Intead of changing in tsconfig i changed loop from entries to forEach and it worked out for me
this.lastviewed.forEach((value: object, key: string) => {//worked
console.log("PRINTING : ", key, value);
});
thanks to thefourtheye answer
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With