Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

z.infer<> fails to infer nested union type. #3703

Open
grogugrogu opened this issue Aug 11, 2024 · 1 comment
Open

z.infer<> fails to infer nested union type. #3703

grogugrogu opened this issue Aug 11, 2024 · 1 comment

Comments

@grogugrogu
Copy link

Hey everyone, I seem to have run into an issue but I'm unsure if this is by design or there's a way around this.
z.infer seems to skip an entire schema and only shows a schema of shared fields only for a nested field with a union type.

field: z
        .union([zod1Schema, zod2Schema])
        .nullable()
        .optional(),

The result is a type that only shows what's shared between the two schemas and ignores fields from zod2Schema.

@powersjcb
Copy link

powersjcb commented Aug 15, 2024

I was having similar issues. Do we know if this a regression or has this always been this way?

I'm working on some repros for this outside of our prod codebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants