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?
Was this page helpful?