Outputting zod definitions for use in a different codebase

Hi, I would like to take my zod schemas and output them for use in another codebase. Unfortunately when using tsc emitDeclaration with: import { z } from 'zod'; const definition = z.string(); export type clientInput = z.input<typeof definition>; comes out with the zod types baked in, even if typescript will show me that thingIWant is a string. In this case I get: import { z } from 'zod'; declare const definition: z.ZodString; export type clientInput = z.input<typeof definition>; export {}; Which really isn't ideal when the types span multiple files and ideally would be in some kind of readable fashion when working with the other codebase. I would love to get export type clientInput = string;
2 Replies
erik.gh
erik.gh13mo ago
have you tried using z.infer<typeof definition> and export that?
gymnocarpa
gymnocarpa13mo ago
I have, what ever zod functions are used, tsc doesn't realise that it doesn't actually need the zod library