UNPKG

@nu-art/commando

Version:
21 lines (20 loc) 1.07 kB
import { Constructor } from '@nu-art/ts-common'; /** * Type utility to recursively merge the types of constructors in an array. * @template T - An array of constructors. */ export type MergeTypes<T extends Constructor<any>[]> = T extends [a: Constructor<infer A>, ...rest: infer R] ? R extends Constructor<any>[] ? A & MergeTypes<R> : {} : {}; /** * Function to merge multiple classes into a single class. * @template T - An array of constructors. * @param {...T} plugins - The constructors to merge. * @returns {Constructor<MergeTypes<T>>} - A new constructor that merges all the provided constructors. */ export declare function MergeClass<T extends Constructor<any>[]>(...plugins: T): Constructor<MergeTypes<T>>; /** * Function to create an instance of a class that merges multiple classes. * @template T - An array of constructors. * @param {...T} plugins - The constructors to merge. * @returns {MergeTypes<T>} - An instance of the merged class. */ export declare function CreateMergedInstance<T extends Constructor<any>[]>(...plugins: T): MergeTypes<T>;