javascript type casting of array not working?

This code does fill in the debug_jp array

var debug : Transform;
var debug_jp : Component[];
debug_jp = debug.root.gameObject.GetComponentsInChildren(JumpPoint, true);

But NOT that code.
why ?

var debug : Transform;
var debug_jp : JumpPoint[];
debug_jp = debug.root.gameObject.GetComponentsInChildren(JumpPoint, true) as JumpPoint[];

so how do I get a typed array from GetComponentsInChildren

GetComponentsInChildren returns a Component[ ]. Unlike lone variables, arrays cannot be automagically typecast (say, from Component[ ] to JumpPoint[ ]; even though Component to JumpPoint will work). But you can loop through them to do it:

var debug : Transform;
var temp : Component[];
temp = debug.root.gameObject.GetComponentsInChildren(JumpPoint, true); 
var debug_jp : JumpPoint[] = new JumpPoint[temp.length];
for (j=0;j<temp.length;j++) {
debug_jp[j] = temp[j];
}

Thanks, that’s what I was using, I was stubbornly trying to make my code more readable