Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
web: Use Zod z.discriminatedUnion more.
Anders Kaseorgaaa6f1653816
diff --git a/web/src/drafts.ts b/web/src/drafts.tsindex 64fb380b1fc..022285f97bd 100644--- a/web/src/drafts.ts+++ b/web/src/drafts.ts@@ -36,7 +36,7 @@ const draft_schema = z.intersection(content: z.string(),updatedAt: z.number(),}),- z.union([+ z.discriminatedUnion("type", [z.object({type: z.literal("stream"),topic: z.string(),@@ -61,7 +61,7 @@ const possibly_buggy_draft_schema = z.intersection(content: z.string(),updatedAt: z.number(),}),- z.union([+ z.discriminatedUnion("type", [z.object({type: z.literal("stream"),topic: z.string().optional(),diff --git a/web/src/state_data.ts b/web/src/state_data.tsindex e1c865ac9e0..296afc556c2 100644--- a/web/src/state_data.ts+++ b/web/src/state_data.ts@@ -43,7 +43,10 @@ const one_time_notice_schema = z.object({type: z.literal("one_time_notice"),});-const onboarding_step_schema = z.union([one_time_notice_schema, hotspot_schema]);+const onboarding_step_schema = z.discriminatedUnion("type", [+ one_time_notice_schema,+ hotspot_schema,+]);export type OnboardingStep = z.output<typeof onboarding_step_schema>;