When using complex zod validators for defining ApiMethods inputs and outputs, an error from typescript is shown:
Type instantiation is excessively deep and possibly infinite
I've researched a bit about it and seems that composing zod types over a single type (the API definition) could the typescript type resolver to throw this error.
Alternatives
- Add a validator field for validating input/output but no inference type is made. So if you wanted to define a method would look like this:
unsubscribe_object_mappings: {
params: defineUnvalidatedType<{subscriptionId: string}>(),
paramsValidation: z.object({
subscriptionId: z.string(),
}),
returns: defineUnvalidatedType<{success: boolean}>(),
returnsValidation: z.object({
success: z.boolean(),
}),
},
- Substitute for another validation library. There are some lighter libraries for validation that would might allow this kind of type inference.
When using complex zod validators for defining
ApiMethodsinputs and outputs, an error from typescript is shown:I've researched a bit about it and seems that composing zod types over a single type (the API definition) could the typescript type resolver to throw this error.
Alternatives