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
Types generated from OpenAPI schema by TypeScript generator are far less strict than one provided by ZOD.
Would be really great if we could use TS types provided by ZOD itself since we do use zod parsing anyway
What is the feature you are proposing to solve the problem?
add option (enabled by default) to pluginZod which would add z.infer<typeof mySchema> to every zod schema generated by kubb (right in the same file as schema)
What alternatives have you considered?
As workaround I do add those types using hooks like so
hooks: {done: ['replace-in-file --configFile=replace.config.cjs',// this should go as first hook otherwise won't work'prettier --loglevel silent generatedTypes/ --write',// we can apply code fomratting after],},
module.exports={files: 'generatedTypes/zod/*.ts',from: /(export const (\w+) .*)$/gm,// this will find every line starting with exportto: '$1\nexport type $2=z.infer<typeof $2>',// this will add one more line after one with export wrapping everything after export with z.infer};
It works quite well for me so far and I really don't see any downside of having this natively handled by kubb
The text was updated successfully, but these errors were encountered:
Hi, Do you have some examples of where TypeScript is less strict? We could adapt the TypeScript plugin to have the same strict types but being dependent on something like Zod is not great(not everybody wants to use Zod and I don't want to force people to use Zod for just types).
I feel, that the ts plugin should not change.
The zod plugin should be able to export types as well, by providing a type output path.
And plugins that have a dependency on the ts plugin, shouldn't or more like they should require zod(with ts path) or ts.
I have the same concern about zod, it would be better to be able to export types with zod as well using zod.infer, this way we don't have the extras types when using zod
What is the problem this feature would solve?
Types generated from OpenAPI schema by TypeScript generator are far less strict than one provided by ZOD.
Would be really great if we could use TS types provided by ZOD itself since we do use zod parsing anyway
External documents/projects?
docs reference below
https://zod.dev/?id=type-inference
What is the feature you are proposing to solve the problem?
add option (enabled by default) to
pluginZod
which would addz.infer<typeof mySchema>
to every zod schema generated by kubb (right in the same file as schema)What alternatives have you considered?
As workaround I do add those types using hooks like so
and content of
replace.config.cjs
(this is config file for https://www.npmjs.com/package/replace-in-file)It works quite well for me so far and I really don't see any downside of having this natively handled by kubb
The text was updated successfully, but these errors were encountered: