From 6d2fce8eb529862c985b8e19ceac1216b3164e23 Mon Sep 17 00:00:00 2001 From: Sathya Gunasekaran Date: Wed, 8 Nov 2023 16:09:16 +0000 Subject: [PATCH] Make CustomHooks optional and add default value Don't propogate nullability into the plugin. --- .../packages/babel-plugin-react-forget/src/HIR/Environment.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/packages/babel-plugin-react-forget/src/HIR/Environment.ts b/compiler/packages/babel-plugin-react-forget/src/HIR/Environment.ts index 895a7f6d6d..94a89447fa 100644 --- a/compiler/packages/babel-plugin-react-forget/src/HIR/Environment.ts +++ b/compiler/packages/babel-plugin-react-forget/src/HIR/Environment.ts @@ -100,7 +100,7 @@ export type Hook = z.infer; */ const EnvironmentConfigSchema = z.object({ - customHooks: z.map(z.string(), HookSchema).nullish(), + customHooks: z.map(z.string(), HookSchema).optional().default(new Map()), // 🌲 enableForest: z.boolean().default(false), @@ -315,7 +315,7 @@ export class Environment { this.#shapes = new Map(DEFAULT_SHAPES); this.config = config; - if (this.config.customHooks != null && this.config.customHooks.size > 0) { + if (this.config.customHooks.size > 0) { this.#globals = new Map(DEFAULT_GLOBALS); for (const [hookName, hook] of this.config.customHooks) { CompilerError.invariant(!this.#globals.has(hookName), {