so I have a function which accepts different constructors, like so:
export class SomeSuperClass {
...
}
export class A extends SomeSuperClass {
...
}
export class B extends SomeSuperClass {
...
}
const foo = function(Clazz: SomeSuperClass){
const v = new Clazz();
}
foo(A); // pass the class itself
foo(B); // pass the class itself
the problem is that SomeSuperClass
means that Clazz
will be an instance of SomeSuperClass
, but not SomeSuperClass
itself.
I tried something stupid like this (which obviously doesn't work):
const foo = function(Clazz: SomeSuperClass.constructor){
const v = new Clazz();
}
what's the right way to do this?