Typescript wizards needed! Circular dependency with Zod inferred schema type withing superRefine()
I have a zod object and I have a
superRefine()
call on the object to do additional validation.
I want to separate the function call from the function within superRefine()
to another validation function that accepts (val, ctx) and performs the validations/adds issues there (see below example.
It works functionality wise however the issue is when I use the z.infer
type of the schema to provide the type of the val
parameter I get a circular dependency error.
How can I type this without creating a whole new duplicate type that doesn't use infer or using any?4 Replies
an example here
the val: SchemaType in the validationRules function here causes the circular dependency error
ps: forgive me i dont type in serif font idk what happened
does this not work for your use case
these are the docs in zod for recursive types are you have one here