Theo's Typesafe CultTTC
Theo's Typesafe Cult9mo ago
3 replies
Joey9

Use ts type in Zod

i have a type that i am importing from a 3rd party package. is there a way i can use this type and put it my object schema. if i just make it an enum and i update the 3rd party package and they change these types, my code would be wrong
// imported type: 
type EmailOtpType = 'signup' | 'invite' | 'magiclink' | 'recovery' | 'email_change' | 'email'

const mySchema = z.object({
    type: /* use imported EmailOtpType here */,
});
Was this page helpful?