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?19 Replies
@yeetcode.io what version do u have installed? i had the same issue yesterday and finally made it work i think mostly due to upgrading to v11 and doing some tsconfig changes
My frontend:
My backend:
And I don't have anything installed in my root folder
Do you know if what your tsconfig settings are? Do you have the same setup as me? @Ofir Smolinsky
I also believe I am supposed to have @trpc/server installed in the frontend, but when I do it doesn't fix anything
And when I try to install that, I get this error:
Root TSConfig:
Frontend TSConfig:
Packages/API TSConfig:
Server TSConfig:
Base TSConfig (the one being inherited in some of these)
NextJS base TSConfig
trpc:
I use turborepo
Structure is a NextJS frontend, express backend in another dir, and a common API package where the appRouter is defined
omg, thank you so much! let me look at this and see if I can figure out what is wrong
let me know if it solve the problem, it was such a headache yesterday lol
and make sure to use this version maybe it will solve, make sure to delete node modules and dists before thinking it dont work
thanks yeah. I think I am having a parallel issue where I was using npm instead of yarn, and
nohoist
doesn't work in npm, so I am trying to migrate to yarn first.what monorepo tool u use btw?
im not using any monorepo tool, which im not sure is the right way to go about it... the backend and frontend are just colocated
is it established repo or new one?
its a few months old
i reccomend turborepo
ahhh i see
is there a benefit to using it? i dont have any shared deps
i only want to colocate the files for TRPC only
but im not sure if im misunderstanding the purpose of a monorepo
i guess TRPC is considered shared dependency : ) but try to solve it without turborepo first
sure, thank you! i iwll get back to you
monorepo is mostly for sharing depndencies yea
Okay, I think I got it working! I migrated to yarn, used yarn workspaces, and removed all absolute paths from by backend
what a nightmare!
yea took me a couple hours yesterday, glad you got it working : )
whatre u working on btw?
I'm working on a social media app! I'll post it here when it is ready
😍