diff --git a/src/utils/lazy.ts b/src/utils/lazy.ts index 899b05f1c..76bcbb159 100644 --- a/src/utils/lazy.ts +++ b/src/utils/lazy.ts @@ -43,6 +43,7 @@ const handler: ProxyHandler = { ...Object.fromEntries(Object.getOwnPropertyNames(Reflect).map(propName => [propName, (target: any, ...args: any[]) => Reflect[propName](target[proxyLazyGet](), ...args)] )), + set: (target, p, newValue) => Reflect.set(target[proxyLazyGet](), p, newValue, target[proxyLazyGet]()), ownKeys: target => { const keys = Reflect.ownKeys(target[proxyLazyGet]()); for (const key of unconfigurable) { @@ -97,7 +98,7 @@ export function proxyLazy(factory: () => T, attempts = 5, isChild const proxy = new Proxy(proxyDummy, { ...handler, - get(target, p, receiver) { + get(target, p) { if (p === proxyLazyGet) return target[proxyLazyGet]; if (p === proxyLazyCache) return target[proxyLazyCache]; @@ -107,7 +108,7 @@ export function proxyLazy(factory: () => T, attempts = 5, isChild // `const { meow } = proxyLazy(() => ({ meow: [] }));` if (!isChild && isSameTick) { return proxyLazy( - () => Reflect.get(target[proxyLazyGet](), p, receiver), + () => Reflect.get(target[proxyLazyGet](), p, target[proxyLazyGet]()), attempts, true ); @@ -115,7 +116,7 @@ export function proxyLazy(factory: () => T, attempts = 5, isChild const lazyTarget = target[proxyLazyGet](); if (typeof lazyTarget === "object" || typeof lazyTarget === "function") { - return Reflect.get(lazyTarget, p, receiver); + return Reflect.get(lazyTarget, p, lazyTarget); } throw new Error("proxyLazy called on a primitive value. This can happen if you try to destructure a primitive at the same tick as the proxy was created."); diff --git a/src/utils/proxyInner.ts b/src/utils/proxyInner.ts index 96d2f4262..2511649a5 100644 --- a/src/utils/proxyInner.ts +++ b/src/utils/proxyInner.ts @@ -22,6 +22,7 @@ const handler: ProxyHandler = { ...Object.fromEntries(Object.getOwnPropertyNames(Reflect).map(propName => [propName, (target: any, ...args: any[]) => Reflect[propName](target[proxyInnerGet](), ...args)] )), + set: (target, p, value) => Reflect.set(target[proxyInnerGet](), p, value, target[proxyInnerGet]()), ownKeys: target => { const keys = Reflect.ownKeys(target[proxyInnerGet]()); for (const key of unconfigurable) { @@ -67,7 +68,7 @@ export function proxyInner( const proxy = new Proxy(proxyDummy, { ...handler, - get(target, p, receiver) { + get(target, p) { if (p === proxyInnerValue) return target[proxyInnerValue]; if (p === proxyInnerGet) return target[proxyInnerGet]; @@ -80,7 +81,7 @@ export function proxyInner( recursiveSetInnerValues.push((innerValue: T) => { // Set the inner value of the destructured value as the prop value p of the parent - recursiveSetInnerValue(Reflect.get(innerValue as object, p, receiver)); + recursiveSetInnerValue(Reflect.get(innerValue as object, p, innerValue)); }); return recursiveProxy; @@ -88,7 +89,7 @@ export function proxyInner( const innerTarget = target[proxyInnerGet](); if (typeof innerTarget === "object" || typeof innerTarget === "function") { - return Reflect.get(innerTarget, p, receiver); + return Reflect.get(innerTarget, p, innerTarget); } throw new Error(primitiveErrMsg);