nuke applyToClass

This commit is contained in:
Yuzuru 2023-06-06 14:27:54 -05:00
parent 4c1c6812e2
commit e7d039f4da
2 changed files with 0 additions and 30 deletions

View File

@ -1,29 +0,0 @@
export function applyToClass<
T extends new (
..._args: ConstructorParameters<T>
) => InstanceType<T>,
U extends new (
..._args: ConstructorParameters<U>
) => InstanceType<U>
// @ts-expect-error
>(structToApply: T, struct: U, ignore?: (keyof T['prototype'])[]) {
const props = Object.getOwnPropertyNames(structToApply.prototype);
for (const prop of props) {
if (ignore?.includes(prop as keyof T) || prop === 'constructor') continue;
Object.defineProperty(struct.prototype, prop, Object.getOwnPropertyDescriptor(structToApply.prototype, prop)!);
}
return struct as unknown as Struct<T, U>;
}
// rome-ignore lint/nursery/noBannedTypes: fix applyToClass typing
export type Struct<ToMix = {}, Final = {}> = Final extends new (
..._args: never[]
) => infer F
? ToMix extends new (
..._args: never[]
) => infer TM
? new (
..._args: ConstructorParameters<Final>
) => F & TM
: never
: never;

View File

@ -2,6 +2,5 @@ export * from './Constants';
export * from './Util'; export * from './Util';
export * from './Types'; export * from './Types';
export * from 'discord-api-types/v10'; export * from 'discord-api-types/v10';
export * from './applyToClass';
export * from './Collection'; export * from './Collection';
export * from './Logger'; export * from './Logger';