gymnocarpa
TTCTheo's Typesafe Cult
•Created by gymnocarpa on 5/17/2023 in #questions
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;
3 replies