Have types exports on generated file?
See original GitHub issueFeature 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
export type MyType = z.number();
Output
export const myTypeSchema = z.number();
export type MyType = z.infer<typeof myTypeSchema>;
Issue Analytics
- State:
- Created a year ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
export type * from 'somewhere' #48508 - GitHub
We have a file that only contains type annotations (https://github.com/babel/babel/blob/main/packages/babel-types/src/ast-types/generated/index.
Read more >Export all interfaces/types from one file in TypeScript project
You can export them directly if you don't need to use them. export * from '../foo/bar';. Or if you need to export only...
Read more >Documentation - Modules - TypeScript
Modules are declarative; the relationships between modules are specified in terms of imports and exports at the file level. Modules import one another...
Read more >Generating a File to Export - Oracle Help Center
Generating a File to Export. Click Import/Export. On the Import/Export Request Parameters page, select the Export option. In the Hierarchy Selection area, ...
Read more >File format options for PDF export - Adobe Support
Generates tags for files that are not already tagged, such as PDFs created using Acrobat 4.0 or earlier. If this option is not...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hi!
Typescript is smart!
Even using infer, it keeps the JSDoc comments from the schema!
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
infer, we just need to make sure to not have any name conflicts when the types are recursive (https://github.com/colinhacks/zod#recursive-types)