mirror of
https://github.com/zulip/zulip.git
synced 2025-11-12 01:47:41 +00:00
web: Use Zod z.discriminatedUnion more.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Anders Kaseorg
parent
a03a26151c
commit
aaa6f16538
@@ -36,7 +36,7 @@ const draft_schema = z.intersection(
|
|||||||
content: z.string(),
|
content: z.string(),
|
||||||
updatedAt: z.number(),
|
updatedAt: z.number(),
|
||||||
}),
|
}),
|
||||||
z.union([
|
z.discriminatedUnion("type", [
|
||||||
z.object({
|
z.object({
|
||||||
type: z.literal("stream"),
|
type: z.literal("stream"),
|
||||||
topic: z.string(),
|
topic: z.string(),
|
||||||
@@ -61,7 +61,7 @@ const possibly_buggy_draft_schema = z.intersection(
|
|||||||
content: z.string(),
|
content: z.string(),
|
||||||
updatedAt: z.number(),
|
updatedAt: z.number(),
|
||||||
}),
|
}),
|
||||||
z.union([
|
z.discriminatedUnion("type", [
|
||||||
z.object({
|
z.object({
|
||||||
type: z.literal("stream"),
|
type: z.literal("stream"),
|
||||||
topic: z.string().optional(),
|
topic: z.string().optional(),
|
||||||
|
|||||||
@@ -43,7 +43,10 @@ const one_time_notice_schema = z.object({
|
|||||||
type: z.literal("one_time_notice"),
|
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>;
|
export type OnboardingStep = z.output<typeof onboarding_step_schema>;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user