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

Casting the schemas to ZodType #79

Closed
ciscoheat opened this issue Feb 9, 2023 · 2 comments
Closed

Casting the schemas to ZodType #79

ciscoheat opened this issue Feb 9, 2023 · 2 comments

Comments

@ciscoheat
Copy link

Hello again, thank you for a great library that's been very helpful. I'm just wondering about the reason for casting many of the generated schemas to z.ZodType, for example:

export const CountryCreateInputSchema: z.ZodType<Prisma.CountryCreateInput> = z.object({
  ...
}).strict();

This is a bit inconvenient, since when it's not typed as a ZodObject, you lose access to helpful methods like shape, pick and omit on those schemas. I've been using sed to remove the casts, but maybe that's not the best thing to do?

@ciscoheat
Copy link
Author

I tried to buy you a coffee but the payment couldn't be processed, tried multiple cards.

@ciscoheat
Copy link
Author

Ok, I figured it out the hard way when VS Code grinded to a halt trying to infer the types when not casted. :) I'm using createInputTypes = false and createOptionalDefaultValuesTypes = true instead, which works very well.

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

1 participant