【发布时间】:2016-11-13 16:18:55
【问题描述】:
在 TypeScript 中,我可以将变量的类型定义为类的类型。例如:
class MyClass { ... }
let myVar: typeof MyClass = MyClass;
现在我想将它与泛型类一起使用,如下所示:
class MyManager<T> {
constructor(cls: typeof T) { ... }
/* some other methods, which uses instances of T */
}
let test = new MyManager(MyClass); /* <MyClass> should be implied by the parameter */
所以,我想给我的管理器类另一个类(它的构造函数),因为管理器需要检索与 类 关联的静态信息。
编译我的代码时,它说找不到名称“T”,我的构造函数在哪里。
知道怎么解决吗?
【问题讨论】: