🎥 Make videos programmatically with React
union
Jonny Burger1bc195bf8842
diff --git a/packages/cli/src/editor/components/RenderModal/SchemaEditor/create-zod-values.ts b/packages/cli/src/editor/components/RenderModal/SchemaEditor/create-zod-values.tsindex 98cc05fd5b..6585589a82 100644--- a/packages/cli/src/editor/components/RenderModal/SchemaEditor/create-zod-values.ts+++ b/packages/cli/src/editor/components/RenderModal/SchemaEditor/create-zod-values.ts@@ -1,6 +1,6 @@import {z} from 'remotion';-export const createZodValues = (schema: z.ZodTypeAny) => {+export const createZodValues = (schema: z.ZodTypeAny): unknown => {const def = schema._def;const typeName = def.typeName as z.ZodFirstPartyTypeKind;@@ -45,7 +45,11 @@ export const createZodValues = (schema: z.ZodTypeAny) => {return [createZodValues(def.type)];}- case z.ZodFirstPartyTypeKind.ZodUnion:+ case z.ZodFirstPartyTypeKind.ZodUnion: {+ const firstOptions = def.options[0];+ return firstOptions ? createZodValues(firstOptions) : undefined;+ }+case z.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:case z.ZodFirstPartyTypeKind.ZodIntersection:case z.ZodFirstPartyTypeKind.ZodTuple:diff --git a/packages/cli/src/test/create-zod-values.test.ts b/packages/cli/src/test/create-zod-values.test.tsindex 16bca3b16f..3a3690216b 100644--- a/packages/cli/src/test/create-zod-values.test.ts+++ b/packages/cli/src/test/create-zod-values.test.ts@@ -26,3 +26,10 @@ test('Should be able to create an array', () => {expect(createZodValues(z.array(z.string()))).toEqual(['']);expect(createZodValues(z.array(z.number()))).toEqual([0]);});++test('Should be able to create a union', () => {+ expect(createZodValues(z.union([z.string(), z.number()]))).toBe('');+ expect(createZodValues(z.union([z.number(), z.string()]))).toBe(0);+ // @ts-expect-error union+ expect(createZodValues(z.union([]))).toBe(undefined);+});