Mugetsu
Mugetsu2y ago

Sharing Enum

On the backend: I have colocated files with types and procedures (index.ts - procedures, schemas.ts - zod/ts types). If I define an Enum on the backend in the schemas.ts and would like to use it on the client(frontend) does it meat that importing that enum would boundle this file in my client? With type I can just do import type { SomeType } from '../backend/schemas' and that would be stripped If I understand correctly. But what about enum?
2 Replies
Nick
Nick2y ago
TS types will get stripped, but if you want the Zod type it might be worth breaking that into a library for peace of mind Treeshaking should do a lot in theory but it’s still better to separate it
Mugetsu
MugetsuOP2y ago
Got it. Thanks for the heads up

Did you find this page helpful?