Replies: 5 comments 7 replies
-
I'm not sure that the question is very clear on what you are wanting? What do you mean by: "without any ties to zod"? Can you not just |
Beta Was this translation helpful? Give feedback.
-
In the Ecosystem section of the docs, it shows other libraries that might do what you are asking.
|
Beta Was this translation helpful? Give feedback.
-
It's a bit convoluted... But you could use the zod-to-json-schema package and then a json-schema-to-ts package or tool such as this one. It should work for most cases, except when there is no logical overlap (such as promises, functions and maps/sets etc). |
Beta Was this translation helpful? Give feedback.
-
I decided to make a library for this, check it out here (zod-to-ts). It converts your schema into a TS AST node. |
Beta Was this translation helpful? Give feedback.
-
This is such a common use case. How you all use backend types in your frontend if not by this? |
Beta Was this translation helpful? Give feedback.
-
I've made a ZOD schema and have an Inferred Type. Now I need to provide this resulting type to the users of our library without any ties to ZOD. Can someone please advise how do I do this?
Currently, generated d.ts file looks like this:
I'm looking for an elegant solution to produce this:
I'm open to any suggestions how to do it. If none are found - I may eventually experiment with TS compiler API and see if I can extract types that way.
Beta Was this translation helpful? Give feedback.
All reactions