This looks like a problem with the typescript compiler, but not sure, maybe I do not understand typescript type inference. Can anybody explain this problem:
I have this simple code to do something on a list of "TypeAs".. the variable "item" is getting type "Any" when it is very clear that the list is of type "TypeA[]". So, to have type safety and intellisense I have to cast the type.
var list: TypeA[] = this.getListOfTypeAs();
for (var item in list) {
var typedItem = (<TypeA> item); //clearly a problem with typescript
Why?
Because Javascript's
for...in
iterates over the property names of an object/array, not the values of the properties.