Closed cesarve77 closed 11 months ago
zod-prisma-types
generate schemas like:
export const UserSchema: z.ZodType<Prisma.UserCreateInput> = z.object({ id: z.string().uuid().optional(), name: z.string.optional(), })
then if I try to
const NameSchema = UserSchema.pick({name: true});
Typescript throw this error:
TS2339: Property 'pick' does not exist on type 'ZodType '.
It can solved using 4.9 TS feature satifsatisfiesaces
export const UserSchema = z.object({ id: z.string().uuid().optional(), name: z.string.optional() }).strict() satisfies z.ZodType<Prisma.OfferCreateInput>
here a demo
https://stackblitz.com/edit/typescript-prb2b6?file=index.ts
@cesarve77 Thanks for the question but this is not possible since zod requires a type annotation for recursive types to work as mentioned #140.
zod-prisma-types
generate schemas like:
then if I try to
Typescript throw this error:
It can solved using 4.9 TS feature satifsatisfiesaces
here a demo
https://stackblitz.com/edit/typescript-prb2b6?file=index.ts