From 084e4325b9eaa26d4c5313f55c2d612579d379fb Mon Sep 17 00:00:00 2001 From: Sathya Gunasekaran Date: Tue, 14 Nov 2023 11:46:23 +0000 Subject: [PATCH] Convert PanicThresholdOptions to zod type --- .../src/Entrypoint/Options.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Options.ts b/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Options.ts index 96cff214eb..41ea2d98e0 100644 --- a/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Options.ts +++ b/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Options.ts @@ -6,25 +6,29 @@ */ import * as t from "@babel/types"; +import { z } from "zod"; import { CompilerErrorDetailOptions } from "../CompilerError"; import { ExternalFunction, PartialEnvironmentConfig } from "../HIR/Environment"; -export type PanicThresholdOptions = +const PanicThresholdOptionsSchema = z.enum([ /* * Any errors will panic the compiler by throwing an exception, which will * bubble up to the nearest exception handler above the Forget transform. * If Forget is invoked through `ReactForgetBabelPlugin`, this will at the least * skip Forget compilation for the rest of current file. */ - | "ALL_ERRORS" + "ALL_ERRORS", /* * Panic by throwing an exception only on critical or unrecognized errors. * For all other errors, skip the erroring function without inserting * a Forget-compiled version (i.e. same behavior as noEmit). */ - | "CRITICAL_ERRORS" + "CRITICAL_ERRORS", // Never panic by throwing an exception. - | "NONE"; + "NONE", +]); + +export type PanicThresholdOptions = z.infer; export type PluginOptions = { environment: PartialEnvironmentConfig | null;