You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all, I really love Zod! I tried a few validation libraries and Zod by far clicked with me the most. I especially love the TypeScript integration and how easy it is to create a pair of type/interface and validator (schema).
I think it would be amazing if (I'm not sure if this is implemented yet, I haven't found something similar) it would be possible to to reverse type inference. Something like this:
This would make using the library much easier if you already have a bunch of existing interfaces, especially if you cannot modify them. Basically, an equivalent of z.object<T> but instead of having an argument schema: T it would have an argument schema: reverseInfer<T>.
I currently use this pretty bad hack because I will never understand types in TypeScript, why are they even turning complete:
First of all, I really love Zod! I tried a few validation libraries and Zod by far clicked with me the most. I especially love the TypeScript integration and how easy it is to create a pair of type/interface and validator (schema).
I think it would be amazing if (I'm not sure if this is implemented yet, I haven't found something similar) it would be possible to to reverse type inference. Something like this:
This would make using the library much easier if you already have a bunch of existing interfaces, especially if you cannot modify them. Basically, an equivalent of
z.object<T>
but instead of having an argumentschema: T
it would have an argumentschema: reverseInfer<T>
.I currently use this pretty bad hack because I will never understand types in TypeScript, why are they even turning complete:
This throws type errors if the schema isn't defined correctly.
The text was updated successfully, but these errors were encountered: