mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-04 14:06:07 +00:00
nuke applyToClass
This commit is contained in:
parent
4c1c6812e2
commit
e7d039f4da
@ -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;
|
|
@ -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';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user