Is it possible to overload whole class with a type definition?
For example, there are two classes that are different only in that if one of them has a generic typedef, it should also accept it in constructor parameter. If not, there is no need for that param and custom constructor.
export abstract class MyClass implements OtherClass {
readonly foo;
static get bar(): string {
return "bar";
}
}
export abstract class MyPayloadClass<T> extends MyClass {
constructor(public readonly payload: T) {
super();
}
}
The goal is to merge these two together. So we only have a MyClass and it optionally has a constructor with payload only if the type <T> is provided.