yeetcode.io
The inferred type of 'trpc' cannot be named without a reference to '...'
I have a monorepo setup like this:
root
-tsconfig.json
-frontend
--tsconfig.json
-backend
--tsconfig.json
I added a reference in the client tsconfig:
I added
"composite": true
to my backend tsconfig.
In my root tsconfig, I have:
However, now in my client, when I create my trpc instance:
export const trpc = createTRPCReact<AppRouter>();
I get a bunch of typing errors:
Where is this coming from and how can I fix it?38 replies
My TRPC hooks are getting typed as `any`
I'm using a Typescript + Express backend (Node.js, version 18), and a React Native (Typescript) frontend. For some reason by TRPC tanstack-query hooks don't seem to be typing things correctly. I am trying to understand why.
I have a monorepo setup with a file structure like this:
root
-frontend
-backend
So the frontend and backend files can import from each other, and everything lives under one
.git
in the root.
In my backend, I create a router and export the type:
Here is an example typing I get when I hover over a procedure in one of my subrouters. I don't return any
in any of my procedures.
In my React Native app, I import the type:
Then in my App.tsx
, I create the trpcClient
:
Now when I use a hook:
My data
gets typed as any
, what am I doing wrong in my setup?7 replies