GetComponentInChildren is not a member of 'Object'

I’m having a problem with GetComponentInChildren. I get an error saying : BCE0019: ‘GetComponentInChildren’ is not a member of ‘Object’.

This is my code:

function SetRandomNumbers ()
{
	for(var child in transform)
	{
		var weight : int;
		weight = Random.Range(0,10);
		child.GetComponentInChildren(TextMesh).text = weight.ToString(); 
	}
}

Thanks for your help!

Declare the type of ‘child’:

 for (var child : Transform in transform)

Without a type, the compiler defaults to Object.