How to cast Array variable in For Each statment

In the following code:

for each (var h:Hero in heroes as Hero)
{
    if (h.type == 0) DoSomething(h);		
}

I receive the error: **Warning: Implicit downcast from ‘Object’ to ‘Hero’.

Hero is a custom class of mine:

class Hero {
	public var myName:String;
	public var type:int; 
	
	function Hero() {
		
	
	}
}

And the Array declaration:

public var heroes:Array = new Array();

How can I cast the return type of the for each statement to stop that warning?

for each (var h in heroes)
{
var hero : Hero = (Hero)h;
if (hero.type == 0) DoSomething(hero);
}

or put this at the top of the file:

#pragma downcast

import System.Collections.Generic;

...

public var heroes:List.<Hero> = new List.<Hero>();

for each (var h:Hero in heroes)
{
}

http://unity3d.com/learn/tutorials/modules/intermediate/scripting/generics

You can’t create Generics in Javascript, but you can use them