-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Have types exports on generated file? #81
Comments
Hello! Just for challenge a bit the feature request, what is your usecase? Normally you should already have the original types around (since this is the source for ts-to-zod) and those types will always be better since they have the documentation for example. You will loose this usefull piece of information if you retrieve the type with |
Also, I wouldn't trust having a separated schema from the type. If I change the type but forget to change the schema, there would be bugs. |
But, if you add extra stuff to the schemas (as the new .trim() to strings) they would be overwritten, right? |
Ah ok, now I get your usecase! you are mutating the generated zod schema! If this is the case, this was not really the intented usage (I'm always happy to be challenged). The idea was to keep the generated file as source of truth and sync with the typescript definition and import/extends the schemas in a separate file. But regarding your screenshot, I get why this is probably not possible in your case.
But now everything make sense 😅 Anyway, this should not be too hard adding an option to generate those |
I came across this tool while looking for something to help us migrate towards Zod with some of our types. We don't really want to keep them in sync, we're looking to move toward Zod as the single source of truth. I understand that this was not the original usecase but this would be really helpful for people who want to do one-time migrations. EDIT: Oh I see there is a linked PR that actually adds this feature. I will look into that. |
Feature description
The generated file only contains the schemas. I would have no problemas for my small files to have the
export type MyType = z.infer<typeof myTypeSchema>
. Looks like I have to add them manually to the generated file.Input
Output
The text was updated successfully, but these errors were encountered: