@samitouri / QOS-React-1 / commits / 3f7b9e23e3

Don't allow null to be passed to validateEnvironmentConfig

zod will throw an error if we pass null, so let's not do this. Adding a temporary workaround until we start validating PluginOptions.

Sathya Gunasekaran committed Nov 8, 2023 at 16:09 UTC 3f7b9e23e38e9338a66e313cd5842a25e23a5668
2 files changed +6 -2
compiler/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts
+5 -1
@@ -257,7 +257,11 @@ export function compileProgram(
257
258 let compiledFn: CodegenFunction;
259 try {
260 - const config = validateEnvironmentConfig(pass.opts.environment);
260 + /*
261 + * TODO(lauren): Remove pass.opts.environment nullcheck once PluginOptions
262 + * is validated
263 + */
264 + const config = validateEnvironmentConfig(pass.opts.environment ?? {});
265 compiledFn = compileFn(fn, config);
266 pass.opts.logger?.logEvent(pass.filename, {
267 kind: "CompileSuccess",
compiler/packages/babel-plugin-react-forget/src/HIR/Environment.ts
+1 -1
@@ -449,7 +449,7 @@ function isHookName(name: string): boolean {
449 }
450
451 export function validateEnvironmentConfig(
452 - partialConfig: PartialEnvironmentConfig | null
452 + partialConfig: PartialEnvironmentConfig
453 ): EnvironmentConfig {
454 const config = EnvironmentConfigSchema.safeParse(partialConfig);
455 if (config.success) {