Monorepo backend/frontend has issue with types inference on router #683
Replies: 1 comment 3 replies
-
Hi @oorestisime! I'm Dosu and I’m helping the orpc team. The type inference issue you’re seeing on the frontend is almost certainly due to TypeScript not being able to fully resolve the types from your backend router across the monorepo boundary. Even though you have The orpc types rely on deep, recursive type inference, and if TypeScript can’t follow the types all the way through (for example, if it’s only seeing .d.ts output or if module resolution isn’t set up to point directly at the backend’s source or output), you’ll get generic types like To fix this, double-check that:
The orpc codebase itself doesn’t show a full monorepo example with cross-app type sharing, but the lack of project references and path mappings in their Next.js playground matches the symptoms you’re seeing [source]. If you set up project references and paths so that the frontend can “see” the backend’s types directly, you should get full type inference and autocomplete for all router procedures. If you’re still stuck, sharing your tsconfig files and the exact import paths might help pinpoint the issue. To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a structure like:
In backend i do
and in the client side i am trying to create a router using
I get autocomplete on .pulse on the client but then nothing on the procedure. Actually the router comes as
On the client side i have the tsconfig with
"references": [{"path": "../backend/"}]
(nextjs project)and on backend side i have composite and declaration true.
The odd thing is that when i create a client from within the backend everything works good.
Any ideas ?
Beta Was this translation helpful? Give feedback.
All reactions