We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
You can continue the conversation there. Go to discussion →
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
In documentation says that we can infer the type from a schema like this:
But when I try this with the example above, I was expecting attributes required by default and optional only for those I set as optional...
import { z } from 'zod'; export const createDiscountCouponSchema = z.object({ accountId: z.number().optional(), coupon: z.string(), additionalDiscount: z.number(), expirationDate: z.date(), status: z.string(), campaign: z.string().optional(), }); export type CreateDiscountCouponDto = z.infer< typeof createDiscountCouponSchema >;
however, I'm receiving all attributes as optionals,
is that right?
I'm using zod 3.22.2 and typescript 5.0.3
3.22.2
5.0.3
The text was updated successfully, but these errors were encountered:
I have the same issue. zod - 3.22.2 (tried with 3.21.4 as well), typescript - 5.1.6
3.21.4
5.1.6
Sorry, something went wrong.
it works for me when i changed strict to true, take a look in docs about that requirements
// tsconfig.json { // ... "compilerOptions": { // ... "strictNullChecks": true } }
it works for me when i changed strict to true, take a look in docs about that requirements // tsconfig.json { // ... "compilerOptions": { // ... "strictNullChecks": true } }
Thanks @dudubernardino, it worked for me
No branches or pull requests
In documentation says that we can infer the type from a schema like this:
But when I try this with the example above, I was expecting attributes required by default and optional only for those I set as optional...
however, I'm receiving all attributes as optionals,
is that right?
I'm using zod
3.22.2
and typescript5.0.3
The text was updated successfully, but these errors were encountered: