Skip to content

Commit

Permalink
fix: typing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
coroiu committed Sep 24, 2024
1 parent 6484460 commit 4579541
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,23 @@ function buildRegisterContentScriptsPolyfill() {
function NestedProxy<T extends object>(target: T): T {
return new Proxy(target, {
get(target, prop) {
if (!target[prop as keyof T]) {
const propertyValue = target[prop as keyof T];

if (!propertyValue) {
return;
}

if (typeof target[prop as keyof T] !== "function") {
return NestedProxy(target[prop as keyof T]);
if (typeof propertyValue === "object") {
return NestedProxy<typeof propertyValue>(propertyValue);
}

if (typeof propertyValue !== "function") {
return propertyValue;

Check warning on line 57 in apps/browser/src/platform/browser/browser-api.register-content-scripts-polyfill.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/platform/browser/browser-api.register-content-scripts-polyfill.ts#L57

Added line #L57 was not covered by tests
}

return (...arguments_: any[]) =>
new Promise((resolve, reject) => {
target[prop as keyof T](...arguments_, (result: any) => {
propertyValue(...arguments_, (result: any) => {
if (chrome.runtime.lastError) {
reject(new Error(chrome.runtime.lastError.message));
} else {
Expand Down

0 comments on commit 4579541

Please sign in to comment.