David
David2mo ago

Turborepo internal package exported procedure context type `any`

I am working on moving our trpc API to a separate internal package away from our next.js app, but running into an issue where the ctx type is any in the Next.js app. Even though the type is shown when I hover the procedure itself. Any idea what this could be?
No description
No description
15 Replies
Edgar
Edgar2mo ago
I got the same message when I was implementing tRPC into my test turborepo and I never got it to work.
David
DavidOP2mo ago
Man, that is unfortunate to hear LOL Hope someone else may have a solution
Edgar
Edgar2mo ago
I found a solution to your problem
Edgar
Edgar2mo ago
GitHub
GitHub - edgar-guzman/small-trpc-example-turbo
Contribute to edgar-guzman/small-trpc-example-turbo development by creating an account on GitHub.
David
DavidOP5w ago
Sick! Could you share what part of this repo solves it / I have to look at? Also feel free to @ me since I may not see it otherwise
Edgar
Edgar5w ago
Yeah I can compress, Do you see the create-context file when viewing the repo? (packages/trpc/src/create-context.ts) and This is one of the way I got this to work and when you hover over the word 'ctx' it should say what typed it is.
David
DavidOP4w ago
This doesn't solve it not working in another package / app though, does it?
Edgar
Edgar4w ago
I use the v11 rc version of tRPC: which is 11.0.0-rc.730
David
DavidOP4w ago
I use 11.0.1
Edgar
Edgar4w ago
Interesting I will try and use the v11 instead of rc Let's me know if this work, I bump up version to 11.0.1
Edgar
Edgar4w ago
Khojo
Khojo3w ago
this is so heartbreaking because i am currently facing the same issue and there's nothing i haven't tried. doesn't work. trpc itself is typed as any. can't get it to work no matter what i do
David
DavidOP4d ago
I got it working by changing the way my internal packages work. What does your setup look like?
Heaveapp
Heaveapp2d ago
I believe that this is a similar problem to this: https://github.com/trpc/trpc/issues/6753 That bug report contains a patch you can use to temporarily fix things.
GitHub
bug: generated .d.ts files leaking un-exported types · Issue #67...
Provide environment information System: OS: macOS 14.5 CPU: (12) arm64 Apple M2 Max Memory: 73.41 MB / 32.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 20.18.0 - ~/.nvm/versions/node/v20.18.0/bin/nod...
Heaveapp
Heaveapp2d ago
using patch-package or pnpm patch

Did you find this page helpful?