我可以在以下情况下确定通用类型
T
吗?class MyClass {
constructor() {
}
GenericMethod<T>(): string {
return typeof(T); // <=== this is flagged by the compiler,
// and returns undefined at runtime
}
}
class MyClass2 {
}
alert(new MyClass().GenericMethod<MyClass2>());