怎样让联合类型,支持静态方法呀?
type Constructor<T = Record<string, any>> = new (...args: any[]) => T;
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
export function Mixin<T extends Constructor[]>(...mixins: T): Constructor<UnionToIntersection<InstanceType<T[number]>>>;
class A {
printA() {
console.log("A");
}
static printAA() {
console.log("AA");
}
}
class B {
printB(sss: string) {
console.log("B");
}
static printBB(sss: string) {
console.log("BB");
}
}
class C extends Mixin(A, B) {
printC() {
this.printA();
this.printB('');
}
static printCC() {
C.printAA(); // 这里没有提示,报错
C.printBB(''); // 这里没有提示,报错
}
}