【发布时间】:2019-04-26 20:05:48
【问题描述】:
是否可以在 TypeScript 中推断类的构造函数类型? 我试过了,但它似乎不起作用:
type Constructor<K> = K extends { new: infer T } ? T : any;
【问题讨论】:
-
怎么样:
type Constructor<K> = K extends { new: () => infer T } ? T : any; -
class Foo {},type CtorOfFoo = typeof Foo -
您可以编辑此内容以显示您要完成的工作的minimal reproducible example 吗?
标签: typescript conditional-types