Better error for primitives on proxyLazy + fix StartupTimings (#2339)

main
Eric 7 months ago committed by GitHub
parent e0becc1ba0
commit cba611c1cc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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…
Cancel
Save