tRPC v11 with Tanstack React Query - queryOptions/mutationOptions methods missing
I'm migrating to the new Tanstack React Query integration for tRPC v11 in a Next.js 15 monorepo, but the
queryOptions
and mutationOptions
methods are not available on my tRPC utilities.
Setup:
- Next.js 15.3.5 with App Router
- tRPC v11.4.3
- @tanstack/react-query v5.79.0
- pnpm workspace monorepo
Issue:
The procedures are being typed as any
due to a TypeScript portability issue with Supabase types in our shared package. When I export
procedures without as any
, the build fails with Supabase cookie type mismatches.
Has anyone encountered similar type inference issues across package boundaries in monorepos?
I've been trying to get a reproduction repo setup and this one is pretty close https://github.com/lassiter/tanstack-trpc-issueGitHub
GitHub - lassiter/tanstack-trpc-issue
Contribute to lassiter/tanstack-trpc-issue development by creating an account on GitHub.
3 Replies
Type portability issues are often just a case of importing the offending type into the file which is complaining about it, though it does indicate a package issue. Might be worth opening an issue with supabase about this
IIRC you usually see this when either:
a. the type isn't exported from the root of the package
b. the package has a /core package which it consumes the type from and (again) doesn't re-export it
A lot of libs including tRPC have tried core packages and then abandoned them for this exact reason
@Nick thanks for the insight! if you have any recs on an approach i'd appreicate it!
My first sentence