Skip to content

Commit

Permalink
fix: test
Browse files Browse the repository at this point in the history
  • Loading branch information
socram03 committed Feb 26, 2025
1 parent b878cdd commit 958fbac
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/deps/mixer.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
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);
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;
const descriptor = Object.getOwnPropertyDescriptor(source, key);
if (descriptor) {
Expand All @@ -21,6 +21,11 @@ export function Mixin<T, C extends TypeClass[]>(...mixins: C): C[number] & T {
// @ts-expect-error
const mixinInstance = new mixin(...args);
copyProperties(this, mixinInstance);
let proto = Object.getPrototypeOf(mixinInstance);
while (proto && proto !== Object.prototype) {
copyProperties(this, proto);
proto = Object.getPrototypeOf(proto);
}
}
}
}
Expand Down

0 comments on commit 958fbac

Please sign in to comment.