How to share the types correctly?
Hey everyone,
I have a basic question regarding sharing types between my Fastify back-end and my Expo front-end. I'm using a monorepo and I'm using pnpm workspaces.
My back-end
package.json
includes:
And types.ts
:
Inside my package.json
for my front-end I do:
This works fine and as expected until I try to use path aliases inside my back-end. I understand why this breaks, but is there a way around it? Is my initial setup already wrong?2 Replies
Using path aliases with tRPC in a monorepo always causes problems. The best solution is to avoid them and use relative imports in your tRPC related files.
But you could try to define your path aliases in both the backend package.json and frontend package.json, e.g. "sync" them
Ah, that's a bummer. I don't enjoy the morse code too much 😄 The issue with adding the path aliases to the frontend as well is that they're the same. I use @ for src in both packages. I also use a lib dir in both.