Better error for primitives on proxyLazy + fix StartupTimings (#2339)
This commit is contained in:
parent
e0becc1ba0
commit
cba611c1cc
2 changed files with 8 additions and 4 deletions
|
@ -17,9 +17,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { LazyComponent } from "@utils/react";
|
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
|
|
||||||
|
import StartupTimingPage from "./StartupTimingPage";
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "StartupTimings",
|
name: "StartupTimings",
|
||||||
description: "Adds Startup Timings to the Settings menu",
|
description: "Adds Startup Timings to the Settings menu",
|
||||||
|
@ -31,5 +32,5 @@ export default definePlugin({
|
||||||
replace: '{section:"StartupTimings",label:"Startup Timings",element:$self.StartupTimingPage},$&'
|
replace: '{section:"StartupTimings",label:"Startup Timings",element:$self.StartupTimingPage},$&'
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
StartupTimingPage: LazyComponent(() => require("./StartupTimingPage").default)
|
StartupTimingPage
|
||||||
});
|
});
|
||||||
|
|
|
@ -116,8 +116,11 @@ export function proxyLazy<T>(factory: () => T, attempts = 5, isChild = false): T
|
||||||
attempts,
|
attempts,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
const lazyTarget = target[kGET]();
|
||||||
return Reflect.get(target[kGET](), p, receiver);
|
if (typeof lazyTarget === "object" || typeof lazyTarget === "function") {
|
||||||
|
return Reflect.get(lazyTarget, p, receiver);
|
||||||
|
}
|
||||||
|
throw new Error("proxyLazy called on a primitive value");
|
||||||
}
|
}
|
||||||
}) as any;
|
}) as any;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue