TypeScriptでジェネリックのコンストラクタ作成関数
http://stackoverflow.com/questions/17382143/how-to-create-a-new-object-from-type-parameter-in-generic-class-in-typescript
コンストラクタ作成関数
コンパイルエラー
http://ari-java.doorblog.jp/
http://stackoverflow.com/questions/17382143/how-to-create-a-new-object-from-type-parameter-in-generic-class-in-typescript
コンストラクタ作成関数
コンパイルエラー
function activatorNotWorking<T extends IActivatable>(type: T): T {
return new T(); // compile error could not find symbol T
}
You need to write this:
newを明示的に表現
function activator<T extends IActivatable>(type: { new(): T ;} ): T {
return new type();
}
var classA: ClassA = activator(ClassA); http://ari-java.doorblog.jp/
コメント