diff --git a/apps/browser/src/platform/browser/browser-api.register-content-scripts-polyfill.ts b/apps/browser/src/platform/browser/browser-api.register-content-scripts-polyfill.ts index b0dc60ed12..cce41a61ee 100644 --- a/apps/browser/src/platform/browser/browser-api.register-content-scripts-polyfill.ts +++ b/apps/browser/src/platform/browser/browser-api.register-content-scripts-polyfill.ts @@ -43,23 +43,17 @@ function buildRegisterContentScriptsPolyfill() { function NestedProxy(target: T): T { return new Proxy(target, { get(target, prop) { - const propertyValue = target[prop as keyof T]; - - if (!propertyValue) { + if (!target[prop as keyof T]) { return; } - if (typeof propertyValue === "object") { - return NestedProxy(propertyValue); - } - - if (typeof propertyValue !== "function") { - return propertyValue; + if (typeof target[prop as keyof T] !== "function") { + return NestedProxy(target[prop as keyof T] as object); } return (...arguments_: any[]) => new Promise((resolve, reject) => { - propertyValue(...arguments_, (result: any) => { + (target[prop as keyof T] as CallableFunction)(...arguments_, (result: any) => { if (chrome.runtime.lastError) { reject(new Error(chrome.runtime.lastError.message)); } else {