[PM-11780] Resolve TypeScript 5.3 compile error
This commit is contained in:
parent
3059662482
commit
0846c2c822
|
@ -43,17 +43,23 @@ function buildRegisterContentScriptsPolyfill() {
|
||||||
function NestedProxy<T extends object>(target: T): T {
|
function NestedProxy<T extends object>(target: T): T {
|
||||||
return new Proxy(target, {
|
return new Proxy(target, {
|
||||||
get(target, prop) {
|
get(target, prop) {
|
||||||
if (!target[prop as keyof T]) {
|
const propertyValue = target[prop as keyof T];
|
||||||
|
|
||||||
|
if (!propertyValue) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof target[prop as keyof T] !== "function") {
|
if (typeof propertyValue === "object") {
|
||||||
return NestedProxy(target[prop as keyof T]);
|
return NestedProxy<typeof propertyValue>(propertyValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof propertyValue !== "function") {
|
||||||
|
return propertyValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (...arguments_: any[]) =>
|
return (...arguments_: any[]) =>
|
||||||
new Promise((resolve, reject) => {
|
new Promise((resolve, reject) => {
|
||||||
target[prop as keyof T](...arguments_, (result: any) => {
|
propertyValue(...arguments_, (result: any) => {
|
||||||
if (chrome.runtime.lastError) {
|
if (chrome.runtime.lastError) {
|
||||||
reject(new Error(chrome.runtime.lastError.message));
|
reject(new Error(chrome.runtime.lastError.message));
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue