schema composition causes Type instantiation is excessively deep and possibly infinite #1276
Replies: 2 comments 6 replies
|
Hi @asyncawaits! I'm Dosu and I’m helping the valibot team. This TypeScript error happens because Valibot's schema composition (especially with large objects and deep use of A known workaround is to use an interface declaration instead of a type alias for your inferred output type. For example, instead of: export type PropertyRHFInterface = v.InferOutput<typeof addPropertySchema>;use: export interface PropertyRHFInterface extends v.InferOutput<typeof addPropertySchema> {}This pattern has been shown to resolve the error in similar cases with Valibot and RTK Query generics [source]. Other general strategies: split your schema into smaller parts, reduce the depth of composition, or use type assertions ( Let me know if you want more details on splitting schemas or other patterns! To reply, just mention @dosu. Share context across your team and agents. Try Dosu. |
|
Can you share a minimal reproduction via the Valibot playground? And can you check if this is fixed in the latest Valibot version? |

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I'm using Valibot version 0.41.0.
All reactions