TypeScript函数构造签名
class Ctor {
name: string
constructor(s: string) {
this.name = s
}
}
type SomeContructor = {
new (s: string): Ctor
}
function fn(ctor: SomeContructor) {
return new ctor('zhangsan.')
}
const f = fn(Ctor)
网友评论