Types in Next.js Client components
I've got a schema (
schema.ts
) which defines my tables, a file for type declarations (types.ts
) with things like export type Product = typeof products.$inferSelect;
How am I supposed to use these types in client components? Since the types.ts
imports from schema.ts
we're no longer in client-only land and I get errors like Cannot resolve module 'fs'
and similar.3 Replies
Hey 👋 @RiskyMH this is a Bat signal
Did you try to specify type in your import?
it's actually interesting; my
types.ts
includes
and
if I only import Product
(even without import type
) , everything works fine. As soon as I want to get my enum, everything breaks 😦@nehalist maybe try to make it const enum (ie it wont do as much bundling and will just replace usage with string)
also you should be able to import everything in the types file as type (id hope)