}\n \u003C/Provider>\n {/* \u003C/TRPCProvider> */}\n \u003C/QueryClientProvider>\n );\n};\n\nexport default AppProvider;\n```\n\n**React Query**\n```typescript\nimport {\n defaultShouldDehydrateQuery,\n QueryClient,\n} from \"@tanstack/react-query\";\nimport SuperJSON from \"superjson\";\n\nexport const createQueryClient = () =>\n new QueryClient({\n defaultOptions: {\n queries: {\n // With SSR, we usually want to set some default staleTime\n // above 0 to avoid refetching immediately on the client\n staleTime: 360 * 1000,\n },\n dehydrate: {\n serializeData: SuperJSON.serialize,\n shouldDehydrateQuery: (query) =>\n defaultShouldDehydrateQuery(query) ||\n query.state.status === \"pending\",\n },\n hydrate: {\n deserializeData: SuperJSON.deserialize,\n },\n },\n });\n````\n\n**Page.tsx**\n```typescript\n\"use client\";\nimport { api } from \"@c/Provider\";\n// import { useTRPC } from \"@c/Provider\";\nimport { useSession } from \"@hwa/client\";\n// import { useQuery } from \"@tanstack/react-query\";\nimport { useRouter } from \"next/navigation\";\n\nconst Home = () => {\n const router = useRouter();\n const session = useSession();\n // const trpc = useTRPC();\n // const { data } = useQuery(trpc.message.getMessage.queryOptions());\n const { data } = api.message.getMessage.useQuery(); // message is undefined\n return (\n \u003Cdiv className=\"\">\n \u003Cp>{data}\u003C/p>\n \u003Cpre\n style={{\n padding: \"10px\",\n fontFamily: \"monospace\",\n whiteSpace: \"pre-wrap\",\n }}\n >\n {JSON.stringify(session, null, 2)}\n \u003C/pre>\n \u003Cbutton\n className=\"rounded border px-6 py-1\"\n onClick={() => router.refresh()}\n >\n Refresh\n \u003C/button>\n \u003C/div>\n );\n};\n\nexport default Home;\n\n```\n\n### Link to reproduction\n\nhttps://github.com/SamJbori/hwaTurbo\n\n### To reproduce\n\nCreate a split BE and FE with Turbo Repo\n\n### Additional information\n\n_No response_\n\n### 👨👧👦 Contributing\n\n- [ ] 🙋♂️ Yes, I'd be down to file a PR fixing this bug!",[3194],{"name":3173,"color":3174},6933,"bug: createTRPCReact return undefined routers on split FE/BE","2025-09-06T23:01:14Z","https://github.com/trpc/trpc/issues/6933",0.6777916,{"description":3201,"labels":3202,"number":3203,"owner":3176,"repository":3176,"state":3177,"title":3204,"updated_at":3205,"url":3206,"score":3207},"### Describe the feature you'd like to request\n\nSo one problem I've noticed that a bunch of people run into with MonoRepo Structures, they are trying to define their types in a module to import into their different services (backend, frontend, other packages) and end up with circular dependencies.\nThey end up importing the AppRouter as a Type from their backend, and since that backend depends on the types defined in their shared type package, they now have a circular dependency.\n\nI understand they could create a seperate package specifically for shared router type definition or import the router from the server in order to use in the other services to avoid this problem, but that can often be considered unpleasant in intra-package-dependencies.\n\nSo, I was thinking it would be nice if there was a seperate method for going about router definition.\n\n### Describe the solution you'd like to see\n\nSo I really see two ways to go about fixing this. I believe the easiest solution would constructing a CLI DevTool that allows the user to run a generate router definition command where you can specify a location to create a generated file for their router. This could mimic the way that Encore.dev goes about Client Generation, however a little more focused in on just the type (at least in an initial release of the tool).\n\nhttps://encore.dev/docs/ts/cli/client-generation\n\nThis also might not be easier than the second method due to the fact that you actually have to code a CLI...\n\n### Describe alternate solutions\n\nSo instead of a CLI, if @trpc/Server had a function or method exposed that allows the user to construct the Router Type by passing in constructed Object of Record\u003CprocedureName, ProcedureOpts> where you define the input & output types, type of procedure, and the Meta... That could prove very useful. Plus you can just define all these types in a shared Type Package, and the backend could take in the type and you wouldn't have to explicitly declare the input and output types of those endpoints. \n\nDoing it this way also would allow us to be able to use UnionType Routers for the backend, where we could create seperate Router Type Definitions to use with different clients to decide what endpoints are exposed to different clients and prevent overexposure of endpoints in more granular instances.\n\n### Additional information\n\n_No response_\n\n### 👨👧👦 Contributing\n\n- [x] 🙋♂️ Yes, I'd be down to file a PR implementing this feature!",[],6835,"feat: AppRouter Type Generation","2025-06-25T12:09:03Z","https://github.com/trpc/trpc/issues/6835",0.6778703,{"description":3209,"labels":3210,"number":3211,"owner":3176,"repository":3176,"state":3212,"title":3213,"updated_at":3214,"url":3215,"score":3216},"### Provide environment information\r\n\r\n```\r\n System:\r\n OS: macOS 12.5.1\r\n CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz\r\n Memory: 6.09 GB / 32.00 GB\r\n Shell: 5.8.1 - /bin/zsh\r\n Binaries:\r\n Node: 18.8.0 - ~/.volta/tools/image/node/18.8.0/bin/node\r\n Yarn: 1.22.17 - ~/.volta/tools/image/yarn/1.22.17/bin/yarn\r\n npm: 8.18.0 - ~/.volta/tools/image/node/18.8.0/bin/npm\r\n Browsers:\r\n Edge: 105.0.1343.33\r\n Firefox: 95.0.2\r\n Safari: 15.6.1\r\n npmPackages:\r\n @trpc/server: 10.0.0-proxy-alpha.76 => 10.0.0-proxy-alpha.76 \r\n```\r\n\r\n### Describe the bug\r\n\r\nI have good reason to believe the following issue is back (search issue history to see previous fixes) with trpc version 10:\r\n\r\n`The inferred type of 'appRouter' cannot be named without a reference to '../../node_modules/@trpc/server/dist/error/formatter.js'. This is likely not portable. A type annotation is necessary.` Also occurs with `'../../node_modules/@trpc/server/dist/core/internals/utils.js'`.\r\n\r\n#1960 fixed this before, is it possible that the same bug has presented again?\r\n\r\n### To reproduce\r\n\r\nWith an esm module, try to use trpc 10. _More specifically, set up a router with routes in the new trpc10 style_. Also, is `composite: true` required with trpc? I couldn't infer types from the client without this set, and without a `\"references\": [{ \"path\": \"../bff\" }],` in the client tsconfig.json.\r\n\r\ntsconfig.json (server):\r\n\r\n```\r\n{\r\n \"compilerOptions\": {\r\n \"skipLibCheck\": true,\r\n \"composite\": true,\r\n \"module\": \"ESNext\",\r\n \"moduleResolution\": \"Node16\",\r\n \"sourceMap\": true,\r\n \"outDir\": \"./dist\",\r\n \"pretty\": true,\r\n \"strict\": true,\r\n \"noUnusedParameters\": true,\r\n \"removeComments\": true,\r\n \"noImplicitReturns\": true,\r\n \"allowSyntheticDefaultImports\": true,\r\n \"esModuleInterop\": true,\r\n \"experimentalDecorators\": true,\r\n \"resolveJsonModule\": true,\r\n \"declaration\": true,\r\n \"declarationMap\": true,\r\n \"rootDir\": \"src\",\r\n \"baseUrl\": \".\",\r\n \"paths\": {\r\n \"@/*\": [\"./src/*\"],\r\n },\r\n },\r\n \"include\": [\r\n \"./src/**/*.ts\"\r\n ],\r\n}\r\n```\r\n\r\n### Additional information\r\n\r\nI've tried the fix in \"paths\", and it doesn't work for me.\r\n\r\n### 👨👧👦 Contributing\r\n\r\n- [ ] 🙋♂️ Yes, I'd be down to file a PR fixing this bug!",[],2717,"closed","bug: The inferred type of 'appRouter' cannot be named without a reference to '../../node_modules/@trpc/server/dist/error/formatter.js'. This is likely not portable. A type annotation is necessary.","2022-10-04T00:17:44Z","https://github.com/trpc/trpc/issues/2717",0.54071856,{"description":3218,"labels":3219,"number":3226,"owner":3176,"repository":3176,"state":3212,"title":3227,"updated_at":3228,"url":3229,"score":3230},"Hello all,\r\n\r\nI'm trying to set up a demo monorepo full ESM + TypeScript and I want to use trpc for the API part. 👌 \r\nI currently have an issue when generating declaration types for the project:\r\n\r\n```\r\nsrc/router.ts:6:14 - error TS2742: The inferred type of 'appRouter' cannot be named without a reference to '../../../node_modules/@trpc/server/dist/internals/procedure.js'. This is likely not portable. A type annotation is necessary.\r\n```\r\n\r\nRelated code is here: https://github.com/jgoux/acme/blob/main/apps/api/src/router.ts#L6\r\n\r\nTo reproduce run these commands:\r\n```bash\r\nyarn\r\nyarn workspace @acme/api build\r\n```\r\n\r\nNote that I'm using `@trpc/server@10.0.0-alpha.22`, the stable version wasn't correctly importable with ESM, discussion about it here: https://discord.com/channels/867764511159091230/894984069291581511/979830057994432522\r\n\r\nWhat's funny is that the `tsc --noEmit` is fine and doesn't report the error. 😂 \r\n\r\nI'm not sure what to do about this particular TS error, this is a new one to me. 🤔 ",[3220,3223],{"name":3221,"color":3222},"wontfix","ffffff",{"name":3224,"color":3225},"🔎 needs more investigation/info","d4c5f9",1945,"Error TS2742 when generating declaration types with trpc.router","2022-10-04T06:08:55Z","https://github.com/trpc/trpc/issues/1945",0.58646876,{"description":3232,"labels":3233,"number":3234,"owner":3176,"repository":3176,"state":3212,"title":3235,"updated_at":3236,"url":3237,"score":3238},"### Provide environment information\n\nSystem:\r\n OS: Windows 10 10.0.22621\r\n CPU: (16) x64 12th Gen Intel(R) Core(TM) i5-12600K\r\n Memory: 13.49 GB / 31.80 GB\r\n Binaries:\r\n Node: 18.12.1 - C:\\Program Files\\nodejs\\node.EXE\r\n Yarn: 3.4.1 - C:\\Program Files\\nodejs\\yarn.CMD\r\n npm: 9.2.0 - C:\\Program Files\\nodejs\\npm.CMD\r\n Browsers:\r\n Edge: Spartan (44.22621.1105.0), Chromium (109.0.1518.55)\r\n Internet Explorer: 11.0.22621.1\r\n npmPackages:\r\n @trpc/client: 10.11.1 => 10.11.1\r\n @trpc/react-query: 10.11.1 => 10.11.1\r\n @trpc/server: 10.11.1 => 10.11.1\r\n typescript: ^4.9.5 => 4.9.5\n\n### Describe the bug\n\nUnder `\"moduleResolution\": \"Node16\"` (or `\"NodeNext\"`), compilation of TypeScript types for the router can fail with error\r\n\r\n```\r\nThe inferred type of 'middleware' cannot be named without a reference to '../../node_modules/@trpc/server/dist/core/middleware.js'. This is likely not portable. A type annotation is necessary.ts(2742)\r\n```\n\n### Link to reproduction\n\nhttps://stackblitz.com/edit/trpc-export-ts2742\n\n### To reproduce\n\nSee repro:\r\n1. Set up package with Typescript\r\n2. Set \"moduleResolution\": \"Node16\"\r\n3. Try to compile types, e.g. via tsc --declaration\n\n### Additional information\n\nRelated issues:\r\n#1945, #2717, #2994\r\n\r\nThe issue with `mergeRouters` started in version `10.11.0` but can be worked around by explicitly typing the export.\r\n```typescript\r\nexport const mergeRouters = trpc.mergeRouters as \u003CTRouters extends AnyRouter[]>(...routerList: [...TRouters]) => MergeRouters\u003CTRouters>;\r\n```\r\n\r\nThe internal types for middleware are not all exported (and are significantly more complicated) so work arounds are aggressively hacky and unsustainable.\r\n\r\nOne additional note is although `router` and `procedure` can be exported here, using them in a generic way causes the same error.\n\n### 👨👧👦 Contributing\n\n- [ ] 🙋♂️ Yes, I'd be down to file a PR fixing this bug!",[],3786,"bug: [ESM] The inferred type of 'middleware'/'mergeRouters' cannot be named without a reference to...","2023-03-07T00:06:27Z","https://github.com/trpc/trpc/issues/3786",0.5984772,{"description":3240,"labels":3241,"number":3243,"owner":3176,"repository":3176,"state":3212,"title":3244,"updated_at":3245,"url":3246,"score":3247},"### Provide environment information\n\n```\n System:\n OS: macOS 15.5\n CPU: (10) arm64 Apple M1 Pro\n Memory: 112.67 MB / 32.00 GB\n Shell: 5.9 - /opt/homebrew/bin/zsh\n Binaries:\n Node: 22.14.0 - ~/.config/nvm/versions/node/v22.14.0/bin/node\n npm: 10.9.2 - ~/.config/nvm/versions/node/v22.14.0/bin/npm\n pnpm: 10.11.1 - ~/.config/nvm/versions/node/v22.14.0/bin/pnpm\n bun: 1.1.33 - ~/.bun/bin/bun\n Browsers:\n Chrome: 137.0.7151.122\n Safari: 18.5\n npmPackages:\n typescript: catalog: => 5.8.3 \n zod: ^3.25.49\n \"@tanstack/react-query\": 5.80.7\n \"@trpc/client\": 11.4.0\n \"@trpc/tanstack-react-query\": 11.4.0\n \"@trpc/server\": 11.4.0\n```\n\n### Describe the bug\n\nWhen calling `createCallerFactory(appRouter)` in `packages/api/src/index.tsx`, I'm getting a TypeScript error \n\n```\nThe inferred type of 'createCaller' cannot be named without a reference to '../../../node_modules/@trpc/server/dist/unstable-core-do-not-import.d-ptrxwuSa.mjs'. This is likely not portable. A type annotation is necessary. ts (2742) [7, 7]\n```\n\n\n### Link to reproduction\n\nhttps://github.com/goszczynskip/trpc-bug-caller\n\n### To reproduce\n\n1. Check out the repo\n2. Install with pnpm\n3. Run pnpm dev (this will build all packages).\n4. Error should be visible\n\n### Additional information\n\n_No response_\n\n### 👨👧👦 Contributing\n\n- [x] 🙋♂️ Yes, I'd be down to file a PR fixing this bug!",[3242],{"name":3173,"color":3174},6834,"bug: The inferred type of 'createCaller' cannot be named without a reference to ...","2025-06-25T15:02:07Z","https://github.com/trpc/trpc/issues/6834",0.6345265,{"description":3249,"labels":3250,"number":3251,"owner":3176,"repository":3252,"state":3212,"title":3253,"updated_at":3254,"url":3255,"score":3256},"./src/pages/api/[...trpc].ts:6:1\r\nType error: The inferred type of 'default' cannot be named without a reference to '.pnpm/next@12.2.0_beenoklgwfttvph5dgxj7na7aq/node_modules/next'. This is likely not portable. A type annotation is necessary.\r\n\r\n 4 | \r\n 5 | // Handle incoming OpenAPI requests\r\n 6 | export default createOpenApiNextHandler({\r\n | ^\r\n 7 | router: appRouter,\r\n 8 | createContext,\r\n 9 | });\r\n\r\n",[],56,"trpc-openapi","[Example NextJS] The inferred type of 'default' cannot be named without a reference","2022-07-11T15:01:19Z","https://github.com/trpc/trpc-openapi/issues/56",0.6478023,{"description":3258,"labels":3259,"number":3261,"owner":3176,"repository":3176,"state":3212,"title":3262,"updated_at":3263,"url":3264,"score":3265},"### Provide environment information\n\n```\n System:\n OS: macOS 15.1.1\n CPU: (10) arm64 Apple M1 Pro\n Memory: 109.83 MB / 16.00 GB\n Shell: 5.9 - /bin/zsh\n Binaries:\n Node: 22.11.0 - /opt/homebrew/opt/node@22/bin/node\n npm: 10.9.0 - /opt/homebrew/opt/node@22/bin/npm\n bun: 1.1.2 - ~/.bun/bin/bun\n Watchman: 2024.12.02.00 - /opt/homebrew/bin/watchman\n Browsers:\n Chrome: 134.0.6998.89\n Safari: 18.1.1\n npmPackages:\n @tanstack/react-query: ^5.63.0 => 5.63.0 \n @trpc/client: ^11.0.0-rc.833 => 11.0.0-rc.833+16e52ebcf \n @trpc/react-query: ^11.0.0-rc.833 => 11.0.0-rc.833+16e52ebcf \n @trpc/server: ^11.0.0-rc.833 => 11.0.0-rc.833+16e52ebcf \n next: ^15.0.1 => 15.1.4 \n react: ^19.0.0 => 19.0.0 \n typescript: ^5.8.2 => 5.8.2 \n\n```\n\n### Describe the bug\n\nThe experimenting `experimental_lazy()` router does not correctly infer type from a router. \n- Suppose that I have a router called `testRouter` with a `ping` procedure on it that is defined as:\n```ts\nimport { TRPCError, type TRPCRouterRecord } from \"@trpc/server\";\nimport { protectedProcedure } from \"../trpc\";\n\nexport const testRouter = {\n ping: protectedProcedure.query(() => {\n return {\n message: \"Pong\",\n };\n }),\n} satisfies TRPCRouterRecord;\n\n```\n- When attempting merging into the root router using `experimental_lazy()`, it will cause the error of `Unsafe assignment of an error typed value.eslint[@typescript-eslint/no-unsafe-assignment](https://typescript-eslint.io/rules/no-unsafe-assignment)` and `Unsafe call of a(n) `error` type typed value.eslint[@typescript-eslint/no-unsafe-call](https://typescript-eslint.io/rules/no-unsafe-call)`\n```ts\nimport { experimental_lazy } from \"@trpc/server\";\n\nconst testRouter = experimental_lazy(() =>\n import(\"./routers/test\").then((m) => m.testRouter),\n); // Unsafe assignment of an error typed value.eslint[@typescript-eslint/no-unsafe-assignment](https://typescript-eslint.io/rules/no-unsafe-assignment) and Unsafe call of a(n) `error` type typed value.eslint[@typescript-eslint/no-unsafe-call](https://typescript-eslint.io/rules/no-unsafe-call)\n```\n- Error details:\n```md\nType 'Promise\u003C{ [key: string]: never; } | { ping: QueryProcedure\u003C{ input: void; output: { message: string; }; }>; onSubscribe: SubscriptionProcedure\u003C{ input: void; output: AsyncIterable\u003C{ message: string; }, never, any>; }>; }>' is not assignable to type 'Promise\u003CAnyRouter | { [key: string]: AnyRouter; }>'.\n Type '{ [key: string]: never; } | { ping: QueryProcedure\u003C{ input: void; output: { message: string; }; }>; onSubscribe: SubscriptionProcedure\u003C{ input: void; output: AsyncIterable\u003C{ message: string; }, never, any>; }>; }' is not assignable to type 'AnyRouter | { [key: string]: AnyRouter; }'.\n Type '{ ping: QueryProcedure\u003C{ input: void; output: { message: string; }; }>; onSubscribe: SubscriptionProcedure\u003C{ input: void; output: AsyncIterable\u003C{ message: string; }, never, any>; }>; }' is not assignable to type 'AnyRouter | { [key: string]: AnyRouter; }'.\n Type '{ ping: QueryProcedure\u003C{ input: void; output: { message: string; }; }>; onSubscribe: SubscriptionProcedure\u003C{ input: void; output: AsyncIterable\u003C{ message: string; }, never, any>; }>; }' is not assignable to type '{ [key: string]: AnyRouter; }'.\n Property 'ping' is incompatible with index signature.\n Property 'createCaller' is missing in type 'QueryProcedure\u003C{ input: void; output: { message: string; }; }>' but required in type 'Router\u003Cany, any>'.ts(2322)\nrouter.d.ts(61, 5): 'createCaller' is declared here.\nrouter.d.ts(46, 71): The expected type comes from the return type of this signature.\n```\n\n### Link to reproduction\n\nhttps://github.com/cobeo2004/budget-buddy\n\n### To reproduce\n\n- Clone the reproduce by using:\n```sh\ngit clone https://github.com/cobeo2004/budget-buddy\n```\n- Install dependencies\n```sh\nnpm install --legacy-peer-deps\n```\n- Navigate to `src/server/api/routers` and define a new router.\n- Once defined, navigate to `root.ts` to test the `experimential_lazy()`.\n\n### Additional information\n\n_No response_\n\n### 👨👧👦 Contributing\n\n- [ ] 🙋♂️ Yes, I'd be down to file a PR fixing this bug!",[3260],{"name":3173,"color":3174},6614,"bug: experimental_lazy does not correctly infer type from router","2025-03-20T12:03:12Z","https://github.com/trpc/trpc/issues/6614",0.66376656,["Reactive",3267],{},["Set"],["ShallowReactive",3270],{"$fTRc1wZytZ_XrK4EfJfei_Sz-An4H4Yy6syhVxH_PVJc":-1,"$fY3iZIjccwl5vIoCMTL62eQzo_WFsQH0bP4bszIRMieI":-1},"/trpc/trpc/2994"]