Sharing the tRPC client across a monorepo

Okay so bare with me because I'm really new to monorepos, and I haven't ever messed with the typescript config so this is all new to me. So I have my router defined in my apps/server, and I'm exporting the routers in my package.json:
"exports": {
"./routers": "./src/routers/index.ts"
},
"exports": {
"./routers": "./src/routers/index.ts"
},
But when I import the type in my code.. for some reason it comes out as any. The main question is how do I fix it, but I'm also curious if there's a more correct way to do this.. I saw for example on cal.com's repo that they have a whole separate package dedicated only to tRPC. But doing that would also mean I have to move my drizzle schemas their own package. And at that point, I'll barely have any code left in the actual server app, which feels wrong. Is it bad practice to export stuff from my server app?
No description
2 Replies
Daniel
DanielOP4w ago
okay, well this is really frustrating, cause I tried everything in this list too..
No description
Daniel
DanielOP4w ago
update - I fixed it by adding:
"references": [
{
"path": "../../apps/server"
}
]
"references": [
{
"path": "../../apps/server"
}
]
to my tsconfig. would love it if someone would explain this to me!

Did you find this page helpful?