The following is an example of the problem I am experiencing at the moment. I'm trying to write a mixin that properly infers and reflects the generic type from the subclass of the class provided to the mixin.
abstract class A<T = {}> {
public abstract init(): T;
}
interface IB {
something: string;
}
class B extends A<IB> {
public init(): IB {
return null;
}
}
type ConstructorOf<T = {}> = new (...args: any[]) => T;
function ApplyC<T extends ConstructorOf<A>>(base: T) {
abstract class C extends base {
}
return C;
}
class D extends ApplyC(B) {
constructor() {
super();
// this.init()
}
}
Where I written this.init(), the intellisense is telling me that I have an overload on init(), one is init(): {} and the other is init(): IB, the problem with this is that I don't want there to appear to be an overload, and I just want the IB one to appear.
I need the T in A<T = {}> to be inferred somehow in the mixin and pass it to ConstructorOf<A> from the base: T provided.