(playground here)
let's say I want to write a function that accepts a class as input (I am writing a mixin following the example in the handbook).
type Constructor = new (...args: Array<any>) => {};
function myFunction<TBase extends Constructor>(Base: TBase) {
return class Child extends Base {
// ...
};
}
I can use it with "normal" classes
class C {
// ...
}
const C2 = myFunction(C);
But the compiler gives me an error if I try to call myFunction on a class with a private constructor
class E {
private constructor() {
// ...
}
}
const E2 = myFunction(E);
with the error Cannot assign a 'private' constructor type to a 'public' constructor type.
but how can I change Constructor (well, the type of Base) to say that "it should be subclassable" and that should accept also classes with a private constructor?