Is there a method in typescript to ensure that a property in an interface must be of type "child subclass C, which extends class P"?
example.ts
import { P } from '/path/to/types'
class C extends P {
...
}
types.ts
// `C` cannot be accessed here
class P {
...
}
interface {
myProp: ???? <-- how to ensure `myProp` is a subclass of P (class, not instance)?
}
Alternatively, I could verify
Object.getPrototypeOf(myProp.prototype) === P.prototype
at runtime. Is there a way to enforce this requirement through types at compile/checker time?