1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-25 12:15:18 +01:00

[PM-11780] Resolve TypeScript 5.3 compile error

This commit is contained in:
Andreas Coroiu 2024-10-01 13:39:36 +02:00 committed by GitHub
parent 3059662482
commit 0846c2c822
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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;
}
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 {