@samitouri / QOS-React-2 / commits / 084e4325b9

Convert PanicThresholdOptions to zod type

Sathya Gunasekaran committed Nov 14, 2023 at 11:46 UTC 084e4325b9eaa26d4c5313f55c2d612579d379fb
1 file changed +8 -4
compiler/packages/babel-plugin-react-forget/src/Entrypoint/Options.ts
+8 -4
@@ -6,25 +6,29 @@
6 */
7
8 import * as t from "@babel/types";
9 +import { z } from "zod";
10 import { CompilerErrorDetailOptions } from "../CompilerError";
11 import { ExternalFunction, PartialEnvironmentConfig } from "../HIR/Environment";
12
12 -export type PanicThresholdOptions =
13 +const PanicThresholdOptionsSchema = z.enum([
14 /*
15 * Any errors will panic the compiler by throwing an exception, which will
16 * bubble up to the nearest exception handler above the Forget transform.
17 * If Forget is invoked through `ReactForgetBabelPlugin`, this will at the least
18 * skip Forget compilation for the rest of current file.
19 */
19 - | "ALL_ERRORS"
20 + "ALL_ERRORS",
21 /*
22 * Panic by throwing an exception only on critical or unrecognized errors.
23 * For all other errors, skip the erroring function without inserting
24 * a Forget-compiled version (i.e. same behavior as noEmit).
25 */
25 - | "CRITICAL_ERRORS"
26 + "CRITICAL_ERRORS",
27 // Never panic by throwing an exception.
27 - | "NONE";
28 + "NONE",
29 +]);
30 +
31 +export type PanicThresholdOptions = z.infer<typeof PanicThresholdOptionsSchema>;
32
33 export type PluginOptions = {
34 environment: PartialEnvironmentConfig | null;