diff --git a/src/wrap.ts b/src/wrap.ts index 5ecca7a..e564cb5 100644 --- a/src/wrap.ts +++ b/src/wrap.ts @@ -45,11 +45,14 @@ export function unwrap(item: T): T { } export function passthroughGet(target: any, prop: string | symbol, thisArg?: any) { - const value = Reflect.get(unwrap(target), prop) + const unwrappedTarget = unwrap(target) + const value = Reflect.get(unwrappedTarget, prop) if (typeof value === 'function') { - thisArg = thisArg || unwrap(target) - const bound = value.bind(thisArg) - return bound + if (value.constructor.name === 'RpcProperty') { + return (...args: unknown[]) => unwrappedTarget[prop](...args) + } + thisArg = thisArg || unwrappedTarget + return value.bind(thisArg) } else { return value }