問題の動作を示すサンプルコード:
export class NodePool {
private tail: Node;
private nodeClass: Function;
private cacheTail: Node;
constructor(nodeClass: Function) {
this.nodeClass = nodeClass;
}
get(): Node {
if (this.tail) {
var node = this.tail;
this.tail = this.tail.previous;
node.previous = null;
return node;
} else {
return new this.nodeClass();
}
}
}
例の17行目(return new ......)により、コンパイラーは次のように文句を言い
ます。タイプ'Function'の値はnewableではありません。
後でインスタンス化できるように、任意のクラスのコンストラクターを変数に格納する適切な方法は何ですか。