[]TypeScript 泛形方法如何传TYPE?

GetComponetInChild(node:laya.display.Node):Laya.Animator
{
for (var index = 0; index < node._childs.length; index++) {
var element:Laya.Animator = node._childs[index].getComponentByType(Laya.Animator);
if (element!=null)
{
return element;
}else
this.GetComponetInChild(node._childs[index],);
 
}
}
如何写成泛型方法呢???编译不通过
GetComponetInChild<T>(node:laya.display.Node):T
{
// var s:=typeof(Laya.Animator);
for (var index = 0; index < node._childs.length; index++) {
var element:Laya.Animator = node._childs[index].getComponentByType(T);
if (element!=null)
{
 
return element;
}else
this.GetComponetInChild(node._childs[index],);
 
}
}
已邀请:

Aar0n

赞同来自:

语法问题不在服务范围内。

要回复问题请先

商务合作
商务合作