@samitouri / QOS-React-2 / commits / 6d2fce8eb5

Make CustomHooks optional and add default value

Don't propogate nullability into the plugin.

Sathya Gunasekaran committed Nov 8, 2023 at 16:09 UTC 6d2fce8eb529862c985b8e19ceac1216b3164e23
1 file changed +2 -2
compiler/packages/babel-plugin-react-forget/src/HIR/Environment.ts
+2 -2
@@ -100,7 +100,7 @@ export type Hook = z.infer<typeof HookSchema>;
100 */
101
102 const EnvironmentConfigSchema = z.object({
103 - customHooks: z.map(z.string(), HookSchema).nullish(),
103 + customHooks: z.map(z.string(), HookSchema).optional().default(new Map()),
104
105 // 🌲
106 enableForest: z.boolean().default(false),
@@ -315,7 +315,7 @@ export class Environment {
315 this.#shapes = new Map(DEFAULT_SHAPES);
316 this.config = config;
317
318 - if (this.config.customHooks != null && this.config.customHooks.size > 0) {
318 + if (this.config.customHooks.size > 0) {
319 this.#globals = new Map(DEFAULT_GLOBALS);
320 for (const [hookName, hook] of this.config.customHooks) {
321 CompilerError.invariant(!this.#globals.has(hookName), {