fix: test

This commit is contained in:
Marcos Susaña 2025-02-26 03:17:44 -04:00
parent b878cdd19e
commit 958fbac02d
No known key found for this signature in database

View File

@ -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);
}
} }
} }
} }