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
rphlmr âš¡
rphlmr ⚡•4mo ago
Hey 👋 @RiskyMH this is a Bat signal Did you try to specify type in your import?
nehalist
nehalist•4mo ago
it's actually interesting; my types.ts includes
export type Product = typeof products.$inferSelect;
export type Product = typeof products.$inferSelect;
and
export enum ProductModule {
Specifications = "specifications",
}
export enum ProductModule {
Specifications = "specifications",
}
if I only import Product (even without import type) , everything works fine. As soon as I want to get my enum, everything breaks 😦
The Safe Fire!
The Safe Fire!•4mo ago
@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)
Want results from more Discord servers?
Add your server