See the following TS snippet:
import { z } from "zod";
const EventNameSchema = z.string().or(z.array(z.string()));
type EventName = z.infer<typeof EventNameSchema>;
// EventName is string | string[]
const EventSchema = z.object({
name: z.string().or(z.array(z.string())) // this is the same as the EventNameSchema
});
type EventWithName = z.infer<typeof EventSchema>;
type EventName2 = EventWithName["name"];
// EventName2 is (string | string[]) & (string | string[] | undefined)
And the TS playground: link
I'm not sure if this is intended or a bug or maybe just a user error. Using zod 3.21.4 and TS 4.8.4
See the following TS snippet:
And the TS playground: link
I'm not sure if this is intended or a bug or maybe just a user error. Using zod
3.21.4and TS4.8.4