how to use types on frontend

Hey guyz, according to: https://discord.com/channels/1043890932593987624/1179496917420490782 it is possible to get types for inserts or reads; thats super dope, but I have a question, I am not sure how to use those types on fronted. Got two folders, one for backend with expressjs + drizzle and second one for frontend (svelte + sveltekit). How can I import those types? backend
export type ProductVariant= typeof productVariant.$inferInsert;
export type ProductVariant= typeof productVariant.$inferInsert;
fronted
???
???
3 Replies
tzezar
tzezarOP13mo ago
sorry, I meant this one: const createProductVariantSchema = createInsertSchema(productVariant); used for inserting
Angelelz
Angelelz13mo ago
This is not a type, this is runtime value. You can import this in the backend:
export type ProductVariant= typeof productVariant.$inferInsert;
export type ProductVariant= typeof productVariant.$inferInsert;
But the validation will bring the drizzle dependency with it probably Also, I'm assuming you're in a monorepo
tzezar
tzezarOP13mo ago
oh what a pity ;/, I thought it would be possible to have one source of truth for zod objects yea
Want results from more Discord servers?
Add your server