Search code examples
typescriptionic4

Type 'IterableIterator<[number, any]>' is not an array type or a string type


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.


Solution

  • I solved it by adding "downlevelIteration": true, in compilerOptions inside tsconfig.josn file. Note my target was es2015