Typescript &引用;新建()=>&引用;在类型脚本构造函数中

Typescript &引用;新建()=>&引用;在类型脚本构造函数中,typescript,Typescript,我刚刚在打字稿中找到了一个我不太懂的地方 export abstract class Presenter<TView> { public viewModel: TView; constructor(private template: new() => TView, ) { } public reset(): void { const model = new this.template(); if (this.viewModel == n

我刚刚在打字稿中找到了一个我不太懂的地方

export abstract class Presenter<TView> {
  public viewModel: TView;

  constructor(private template: new() => TView,
  ) {
  }

  public reset(): void {
    const model = new this.template();

    if (this.viewModel == null) {
      this.viewModel = model;
    } else {
      Object.assign(this.viewModel, model);
    }
  }
}
在这里

但我不能不理解这一点。这不是一个函数声明——我从未在这样的上下文中看到过“new”。 我也不知道:

const model = new this.template();
意味着比。
有人能解释一下吗?

这意味着
模板
是一个没有参数的构造函数,当使用
新建
调用时,它返回一个
TView
。typescript手册中对此进行了描述。

这是否回答了您的问题?
const model = new this.template();