for-in statement

typescript

Solution

The for-in statement is really there to enumerate over object properties, which is how it is implemented in TypeScript. There are some issues with using it on arrays.

I can't speak on behalf of the TypeScript team, but I believe this is the reason for the implementation in the language.

Problem

TypeScript docs say nothing about loop like `for` or `for-in`. From playing with the language it seems that only `any` or `string` variables are supported in `for` loop. Why has this decision been made? Why not use the type information and have strongly-typed iteration variable?

Original source

Related problems