Flow 的概念是您可以编写以下类型定义来引用从另一个类继承的类:
function getHouseClass(): Class<House> {}
这是指类,而不是类的实例。
Typescript 中有类似的概念吗?
Class<House>
显然在 TS 中不起作用。
谢谢!
最佳答案
我认为@toskv 是正确的。如果你看this两者之间的比较(在“访问类的类型”标题下方):
流
class Test {};
type TestType = Class<Test>;
// This should be equivalent to (if you can confirm, please send a PR):
type TestType = typeof Test;
typescript
class Test {};
type TestType = typeof Test;
下面应该是一样的:
function getHouseClass(): typeof House { return House; }
关于 typescript 类引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46110985/