Closed
Description
Zod version: zod@3.25.0-beta.20250517T081109
import { z } from 'zod/v4';
const MyResult = z.discriminatedUnion([
z.object({ status: z.literal('success'), data: z.string() }),
z.object({ status: z.literal('failed'), error: z.string() }),
]);
// Works as expected.
MyResult.def.options.length;
// Does not work.
// I understand this is considered a legacy approach,
// yet TypeScript still treats this as valid code.
// This will throw a TypeError at runtime because `options` is `undefined`.
MyResult.options.length;
Metadata
Metadata
Assignees
Labels
No labels