this is a very common usage of javascript or typescript foreach:
myArray = ["a","b","c"]
for(var index in myArray)
console.log(myArray[index])
the code logs: a b and c
However in typescript the "index" var is considered to be a string. . When I make any calculations, for instance index*2, the TS compuler shows the fallowing compiler error:
for(var index in myArray)
console.log(index * 2); // TS compiler error.
Error TS2362 The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type
but logs 0,2 and 4 when executed (as expected)
How can I avoid or suppres this error?