import type { Constructable } from '../decorator/type/constructable.ts'; import { copyMetadataOfClasses, copyPropertiesOfClasses } from './utils.ts'; type UnionToIntersection = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never; type ClassRefsToConstructors = { [U in keyof T]: T[U] extends Constructable ? V : never; }; type Intersection = Constructable[number]>>; export function MixinClass(...classRefs: T): Intersection { abstract class TargetClass {} copyMetadataOfClasses( TargetClass.prototype, classRefs.map(item => item.prototype), ); copyPropertiesOfClasses(TargetClass as any, classRefs); return TargetClass as any; }