如何使用接口注释构造函数

时间:2018-07-12 11:35:11

标签: typescript

在以下代码中:

interface Person {}
interface PersonConstructor {
    new (): Person;
}

let Person: PersonConstructor = function () {};
let person: Person = new Person();

我收到错误消息:

[ts]
Type '() => void' is not assignable to type 'PersonConstructor'.
Type '() => void' provides no match for the signature 'new (): Person'.

用接口注释构造函数的正确方法是什么?

0 个答案:

没有答案