如何键入提示类,而不是类的实例?
我试过了,但我得到了 Cannot use 'new' with an expression whose type lacks a call or construct signature.
class Foo {
}
class Bar extends Foo {
}
class Baz extends Foo {
}
function test(c: Foo) {
new c();
}
test(Baz);
最佳答案
使用 typeof
:
class Foo {
}
class Bar extends Foo {
}
class Baz extends Foo {
}
function test(c: typeof Foo) {
new c();
}
test(Baz);
关于typescript - 如何键入提示类,而不是类的实例?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32322624/