mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-01 20:46:08 +00:00
fix: test
This commit is contained in:
parent
b878cdd19e
commit
958fbac02d
@ -1,8 +1,8 @@
|
|||||||
const IgnoredProps = ['constructor', 'prototype', 'name'];
|
const IgnoredProps = ['constructor', 'prototype', 'name'];
|
||||||
export function copyProperties(target: InstanceType<TypeClass>, source: TypeClass, ignored?: string[]) {
|
export function copyProperties(target: InstanceType<TypeClass>, source: TypeClass) {
|
||||||
const keys = Reflect.ownKeys(source);
|
const keys = Reflect.ownKeys(source);
|
||||||
for (const key of keys) {
|
for (const key of keys) {
|
||||||
if (IgnoredProps.concat(ignored ?? []).includes(key as string)) continue;
|
if (IgnoredProps.includes(key as string)) continue;
|
||||||
if (key in target) continue;
|
if (key in target) continue;
|
||||||
const descriptor = Object.getOwnPropertyDescriptor(source, key);
|
const descriptor = Object.getOwnPropertyDescriptor(source, key);
|
||||||
if (descriptor) {
|
if (descriptor) {
|
||||||
@ -21,6 +21,11 @@ export function Mixin<T, C extends TypeClass[]>(...mixins: C): C[number] & T {
|
|||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
const mixinInstance = new mixin(...args);
|
const mixinInstance = new mixin(...args);
|
||||||
copyProperties(this, mixinInstance);
|
copyProperties(this, mixinInstance);
|
||||||
|
let proto = Object.getPrototypeOf(mixinInstance);
|
||||||
|
while (proto && proto !== Object.prototype) {
|
||||||
|
copyProperties(this, proto);
|
||||||
|
proto = Object.getPrototypeOf(proto);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user