\n\n### Link to reproduction\n\nhttps://github.com/brandongit2/trpc-tanstack-router-bug-repro/blob/main/index.ts\n\n### To reproduce\n\n1. Clone the repro repo\n2. `pnpm install`\n3. Open `index.ts`\n4. Type error:\n ```ts\n Type 'QueryClient' is not assignable to type 'QueryClient | (() => QueryClient)'.\n Type 'import(\"/Users/brandontsang/projects/trpc-tanstack-router-bug-repro/node_modules/.pnpm/@tanstack+query-core@5.66.4/node_modules/@tanstack/query-core/build/modern/hydration-k2LfsAVL\", { with: { \"resolution-mode\": \"import\" } }).b' is not assignable to type 'import(\"/Users/brandontsang/projects/trpc-tanstack-router-bug-repro/node_modules/.pnpm/@tanstack+query-core@5.66.4/node_modules/@tanstack/query-core/build/modern/hydration-BHYO6Wdv\").b'.\n Property '#private' in type 'QueryClient' refers to a different member that cannot be accessed from within type 'QueryClient'.\n ```\n\n### Additional information\n\nThis comes from the fact that `@trpc/tanstack-react-query` doesn't have dedicated ESM type exports.\n\n- In my repro, I have:\n - `\"type\": \"module\"` in `package.json`\n - `\"moduleResolution\": \"nodenext\"` in my `tsconfig.json`\n- When I import from `@tanstack/react-query`, the `.d.ts` files are interpereted as ESM by TypeScript, since they have dedicated ESM type declarations:\n - \u003Cimg width=\"300\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/02697f38-cd10-45ba-b0e3-380b3a7cf568\" />\n- But when I import from `@trpc/tanstack-react-query`, the `.d.ts` files are interpereted as CJS by TypeScript, since the `package.json` doesn't specify `\"type\"`.\n- When `@trpc/tanstack-react-query`'s types import `@tanstack/react-query`, they come in as CJS types. `@tanstack/react-query`'s ESM and CJS types don't seem to be compatible with one another.\n\nIt could be argued that this is also a TanStack Query bug, since their ESM and CJS types ought to be compatible with one another anyway.\n\n---\n\n### Workarounds/fixes:\n\n1. Patch `@trpc/tanstack-react-query` to force ESM imports:\n - Find the `.d.ts` file that imports `@tanstack/react-query` (in this repro's case, it's `@trpc/tanstack-react-query/dist/internals/createOptionsProxy.d.ts`)\n - add an import attribute: `...from '@tanstack/react-query' with {'resolution-mode': 'import'}`\n - Type error gone!\n2. Or, in the user's project, import `@tanstack/react-query` as CJS and override the type:\n - \u003Cimg width=\"951\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/2bc65705-b4b9-45bd-bdf7-6213bebedee2\" />\n - Type error gone!\n\n### ๐จโ๐งโ๐ฆ Contributing\n\n- [ ] ๐โโ๏ธ Yes, I'd be down to file a PR fixing this bug!",[2867,2870],{"name":2868,"color":2869},"๐ bug","d73a4a",{"name":2871,"color":2872},"๐โโ๏ธ help wanted","008672",6554,"trpc","open","bug: Type incompatibility between `@trpc/tanstack-react-query` and `@tanstack/react-query`","2025-03-01T23:59:14Z","https://github.com/trpc/trpc/issues/6554",0.6978465,{"description":2881,"labels":2882,"number":2886,"owner":2874,"repository":2874,"state":2875,"title":2887,"updated_at":2888,"url":2889,"score":2890},"### Provide environment information\n\n``` \nSystem:\n OS: macOS 14.5\n CPU: (12) arm64 Apple M2 Max\n Memory: 73.41 MB / 32.00 GB\n Shell: 5.9 - /bin/zsh\n Binaries:\n Node: 20.18.0 - ~/.nvm/versions/node/v20.18.0/bin/node\n Yarn: 1.22.22 - ~/Library/pnpm/yarn\n npm: 10.8.2 - ~/.nvm/versions/node/v20.18.0/bin/npm\n Browsers:\n Chrome: 135.0.7049.117\n Edge: 134.0.3124.62\n Safari: 17.5\n npmPackages:\n @trpc/server: ^11.1.2 => 11.1.2 \n typescript: ^5.8.3 => 5.8.3 \n```\n\n### Describe the bug\n\nWhen using the documented pattern for defining a router (verbatim from https://trpc.io/docs/server/routers), TypeScript emits declaration files that include imports from `@trpc/server/dist/unstable-core-do-not-import`, which is not exposed via the packageโs exports field.\n\nThis makes the generated `.d.ts` files invalid for consumers that rely on strict ESM resolution, including build tools and downstream libraries.\n\n### Link to reproduction\n\nhttps://github.com/extradosages/trpc-type-leak-demo\n\n### To reproduce\n\nUse the following `trpc.ts` and `router.ts` files (copied verbatim from the docs):\n\n`trcp.ts`\n```ts\nimport { initTRPC } from '@trpc/server';\nconst t = initTRPC.create();\nexport const router = t.router;\nexport const publicProcedure = t.procedure;\n```\n\n`router.ts`\n```ts\nimport { publicProcedure, router } from './trpc';\nconst appRouter = router({\n greeting: publicProcedure.query(() => 'hello tRPC v10!'),\n});\nexport type AppRouter = typeof appRouter;\n```\n\nRun:\n```bash\ntsc --emitDeclarationOnly\n```\n\nObserve that `router.d.ts` includes:\n```ts\ndeclare const appRouter: import(\"@trpc/server/dist/unstable-core-do-not-import\").BuiltRouter\u003C...>;\n```\n\nCompare to the `package.json` `exports` field:\n```json\n\"exports\": {\n \".\": {\n \"import\": \"./dist/index.mjs\",\n ...\n },\n ...\n \"./unstable-core-do-not-import\": {\n \"import\": \"./dist/unstable-core-do-not-import.mjs\",\n ...\n }\n}\n```\n\n### Additional information\n\nMight be solved by https://github.com/trpc/trpc/issues/5004.\n\nCurrently running a workaround in production with the following patch:\n```diff\ndiff --git a/package.json b/package.json\nindex 1f03d01bd1148bffc1434ac66f9feb52ba654bc3..f73cdbd446c2421a377af8ce0459288e1ee1162b 100644\n--- a/package.json\n+++ b/package.json\n@@ -73,6 +73,11 @@\n \"require\": \"./dist/adapters/ws.js\",\n \"default\": \"./dist/adapters/ws.js\"\n },\n+ \"./dist/*\": {\n+ \"import\": \"./dist/*\",\n+ \"require\": \"./dist/*\",\n+ \"default\": \"./dist/*\"\n+ },\n \"./http\": {\n \"import\": \"./dist/http.mjs\",\n \"require\": \"./dist/http.js\",\n```\n\n### ๐จโ๐งโ๐ฆ Contributing\n\n- [ ] ๐โโ๏ธ Yes, I'd be down to file a PR fixing this bug!",[2883],{"name":2884,"color":2885},"๐ bug: unconfirmed","e99695",6753,"bug: generated `.d.ts` files leaking un-exported types","2025-05-07T23:42:57Z","https://github.com/trpc/trpc/issues/6753",0.7094972,{"description":2892,"labels":2893,"number":2897,"owner":2874,"repository":2874,"state":2875,"title":2898,"updated_at":2899,"url":2900,"score":2901},"### Describe the feature you'd like to request\n\nI am using trpc in bunch of projects that are spread across npm packages. E.g., I have a server `my-server` and a client `my-client`. In `my-client` code I am importing `AppRouter` like this:\r\n```ts\r\nimport type { AppRouter } from `my-server`;\r\n```\r\nI want to be able to publish `AppRouter` types on NPM without exposing any sensitive information like my server source code or `Context` of the `AppRouter`.\n\n### Describe the solution you'd like to see\n\nWhen generating .d.ts files via `tsc` or `vite`, .d.ts files contain all imported type definitions. Since `AppRouter` depends on `Context`, and `Context` usually contains all backend services (e.g., `UsersService`, `PaymentService`, etc), all the backend type declarations are also included in .d.ts files.\r\n\r\nI see at least two solutions:\r\n- Somehow replace `Context` object with `unknown` when generating .d.ts files\r\n- If `appRouter` is defined in `src/router.ts`, only include `dist/router.d.ts` in package.json `files` field.\r\n\r\nI hope trpc provides a recommended way to publish `AppRouter`, so developers do not need to think about it themselves.\n\n### Describe alternate solutions\n\nDon't provide a recommended way of publishing `AppRouter` and leave it to devs.\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!",[2894],{"name":2895,"color":2896},"โญ major bump needed","242271",5004,"feat: publishing AppRouter without hassle","2025-03-20T15:42:01Z","https://github.com/trpc/trpc/issues/5004",0.71075284,{"description":2903,"labels":2904,"number":2911,"owner":2874,"repository":2874,"state":2912,"title":2913,"updated_at":2914,"url":2915,"score":2916},"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. ๐ค ",[2905,2908],{"name":2906,"color":2907},"wontfix","ffffff",{"name":2909,"color":2910},"๐ needs more investigation/info","d4c5f9",1945,"closed","Error TS2742 when generating declaration types with trpc.router","2022-10-04T06:08:55Z","https://github.com/trpc/trpc/issues/1945",0.69472635,{"description":2918,"labels":2919,"number":2921,"owner":2874,"repository":2874,"state":2912,"title":2922,"updated_at":2923,"url":2924,"score":2925},"Hi there,\r\n\r\nfirst of all: Thanks a lot for creating trpc :) I just recently stumpled upon it and I'm quite enthusiastic about it's design.\r\n\r\nNow to the problem:\r\n\r\nI'm trying to use trpc in a pnpm-driven monorepo. When I try to compile the package that's using trpc (both `@trpc/server` and `@trpc/client`), `tsc` fails with:\r\n\r\n```\r\n../../../../node_modules/.pnpm/@trpc+server@9.23.4/node_modules/@trpc/server/dist/declarations/src/adapters/node-http/types.d.ts:3:16 - error TS2307: Cannot find module 'qs' or its corresponding type declarations.\r\n\r\n3 import qs from 'qs';\r\n\r\n[...]\r\n\r\n../../../../node_modules/.pnpm/@trpc+server@9.23.4/node_modules/@trpc/server/dist/declarations/src/adapters/standalone.d.ts:5:107 - error TS2344: Type 'IncomingMessage' does not satisfy the constraint 'NodeHTTPRequest'.\r\n Type 'IncomingMessage' is not assignable to type '{ method?: string; query?: any; body?: unknown; }' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.\r\n Types of property 'method' are incompatible.\r\n Type 'string | undefined' is not assignable to type 'string'.\r\n Type 'undefined' is not assignable to type 'string'.\r\n\r\n5 export declare type CreateHTTPHandlerOptions\u003CTRouter extends AnyRouter> = NodeHTTPHandlerOptions\u003CTRouter, http.IncomingMessage, http.ServerResponse>;\r\n```\r\n\r\nThe first one\r\n```\r\nTS2307: Cannot find module 'qs' or its corresponding type declarations.\r\n```\r\n\r\ncan be fixed by installing `@types/qs`. However, I don't think that should be necessary.\r\n\r\nThe second one\r\n```\r\nTS2344: Type 'IncomingMessage' does not satisfy the constraint 'NodeHTTPRequest'.\r\n```\r\nisn't explicable to me but at least resembles one of the errors documented in #1022.\r\n\r\nThis issue was closed by #1151, which should be included with the trpc version I'm using (9.23.4).\r\n\r\nIt's possible that this is related to my use of pnpm.\r\n\r\nAny hint would be appreciated :) I'll keep you posted, if I find anything myself.",[2920],{"name":2868,"color":2869},1904,"Type Errors","2022-10-04T12:02:52Z","https://github.com/trpc/trpc/issues/1904",0.69787437,{"description":2927,"labels":2928,"number":2932,"owner":2874,"repository":2874,"state":2912,"title":2933,"updated_at":2934,"url":2935,"score":2936},"### Area of Improvement\r\n\r\nIssue: Documentation Improvement - Missing 'express' import in adapters/express.md\r\n\r\n\r\n### Link to related docs\r\n\r\nhttps://trpc.io/docs/server/adapters/express#3-use-the-express-adapter\r\n\r\n### Additional information\r\n\r\n**Issue: Documentation Improvement - Missing 'express' import in adapters/express.md**\r\n\r\n**Description:**\r\nThe documentation in `adapters/express.md` is missing an important 'express' import statement. This oversight can potentially lead to confusion for users following the example, as it's a crucial dependency for tRPC with Express.\r\n\r\n**Steps to Reproduce:**\r\n1. Navigate to the documentation file: `adapters/express.md`.\r\n2. Observe the absence of the 'express' import statement.\r\n\r\n**Proposed Improvement:**\r\nAdd the following line to the documentation example:\r\n```typescript\r\nimport express from 'express';\r\n```\r\n\r\n\r\n### ๐จโ๐งโ๐ฆ Contributing\r\n\r\n- [x] ๐โโ๏ธ Yes, I'd be down to file a PR implementing the suggested changes!\r\n\r\n",[2929],{"name":2930,"color":2931},"๐ documentation / examples","0075ca",5372,"fix : Missing 'express' import in adapters/express.md documentationdocs: ","2024-01-22T12:02:20Z","https://github.com/trpc/trpc/issues/5372",0.699785,{"description":2938,"labels":2939,"number":2946,"owner":2874,"repository":2874,"state":2912,"title":2947,"updated_at":2948,"url":2949,"score":2950},"### Provide environment information\r\n\r\n```\r\n System:\r\n OS: macOS 12.6\r\n CPU: (8) arm64 Apple M1 Pro\r\n Memory: 102.69 MB / 16.00 GB\r\n Shell: 5.8.1 - /bin/zsh\r\n Binaries:\r\n Node: 18.12.1 - ~/Library/Caches/fnm_multishells/33773_1664501269786/bin/node\r\n Yarn: 1.22.18 - ~/.nvm/versions/node/v16.13.0/bin/yarn\r\n npm: 8.19.2 - ~/Library/Caches/fnm_multishells/33773_1664501269786/bin/npm\r\n Browsers:\r\n Brave Browser: 107.1.45.133\r\n Chrome: 108.0.5359.124\r\n Firefox: 108.0.1\r\n Safari: 16.0\r\n npmPackages:\r\n @tanstack/react-query: ^4.20.4 => 4.20.4\r\n @trpc/client: ^10.7.0 => 10.7.0\r\n @trpc/next: ^10.7.0 => 10.7.0\r\n @trpc/react-query: ^10.7.0 => 10.7.0\r\n @trpc/server: ^10.7.0 => 10.7.0\r\n next: ^12.2.5 => 12.3.4\r\n react: ^17.0.2 => 17.0.2\r\n typescript: ^4.7.4 => 4.9.4\r\n ```\r\n\r\n### Describe the bug\r\n\r\nI have monorepo setup with Lambda backend and Next frontend.\r\n\r\nAdding `createTRPCNext` with the backend router throws the type error:\r\n\r\n> Types of property '_def' are incompatible.\r\n\r\nFull error:\r\n```\r\nType 'CreateRouterInner\u003CRootConfig\u003C{ ctx: { event: APIGatewayProxyEventV2; }; meta: object; errorShape: never; transformer: DataTransformerOptions; }>, { ...; }>' does not satisfy the constraint 'Router\u003CAnyRouterDef\u003CAnyRootConfig, any>>'. ย ย Types of property '_def' are incompatible. ย ย ย ย Type 'RouterDef\u003CRootConfig\u003C{ ctx: { event: APIGatewayProxyEventV2; }; meta: object; errorShape: never; transformer: DataTransformerOptions; }>, { ...; }, { ...; }>' is not assignable to type 'AnyRouterDef\u003CAnyRootConfig, any>'.\r\n```\r\n\r\nLooks like adapters are incompatible.\r\n\r\n```\r\n// backend/.../router\r\n\r\nimport { AppContext } from './server'\r\n\r\nexport const t = initTRPC.context\u003CAppContext>().create()\r\n\r\nexport const router = t.router({\r\n greeting: t.procedure.query(\r\n () => 'Hello'\r\n ),\r\n})\r\n\r\nexport type ApiRouter = typeof router\r\n```\r\n```\r\n// backend/.../server.ts\r\nexport const appContext = ({\r\n event,\r\n}: CreateAWSLambdaContextOptions\u003CAPIGatewayProxyEventV2>) => event\r\n\r\nexport const handler = awsLambdaRequestHandler({\r\n router,\r\n createContext: appContext,\r\n})\r\n\r\n```\r\n\r\n```\r\n// frontend/util/trpc.ts\r\nimport type { ApiRouter } from '../../backend/src/app/api/trpc/router'\r\n\r\nexport const trpc = createTRPCNext\u003CApiRouter>...\r\n```\r\n\r\n\r\n### Link to reproduction\r\n\r\nhttps://www.example.com\r\n\r\n### To reproduce\r\n\r\nSorry, difficult to provide easily create reproductive repo due to the monorepo setup.\r\nI can try to do add something if its really needed.\r\n\r\n### Additional information\r\n\r\n_No response_\r\n\r\n### ๐จโ๐งโ๐ฆ Contributing\r\n\r\n- [ ] ๐โโ๏ธ Yes, I'd be down to file a PR fixing this bug!",[2940,2943],{"name":2941,"color":2942},"๐ป invalid","e4e669",{"name":2944,"color":2945},"โฎ needs reproduction","000055",3484,"bug: TRPCNext adapter is incompatible with Lambda Adapter","2023-01-11T00:43:15Z","https://github.com/trpc/trpc/issues/3484",0.70123255,{"description":2952,"labels":2953,"number":2957,"owner":2874,"repository":2874,"state":2912,"title":2958,"updated_at":2959,"url":2960,"score":2961},"Some recommendations for improvements to the API:\r\n\r\n- I don't really see any reason to split up `@trpc/server` and `@trpc/client`. I think they should be merged into a single `trpc` module. It makes the out-of-the-box experience so much cleaner.\r\n- Then the `@trpc` scope can be used for specific plugins/adapters etc. You could publish the Express adapter as `@trpc/express` for instance. That would also let you properly specify all the requisite peerDependencies (which I don't believe are specified using the current `@trpc/server/adapters/express` approach since it doesn't have its own package.json.\r\n- I think `import * as` imports are a bad user experience. I submitted a PR with a solution.\r\n- Simplify the function names: `createTRPCClient` => `createClient`, `createNextApiHandler` => `createHandler`, `CreateNextContextOptions` => `ContextOptions`. It should be standard across adapters. It's obvious that a function called `createHandler` imported from `\"@trpc/server/adapters/next\"` is creating a Next.js API handler. It doesn't need to be in the name.\r\n- The adapters should export a `createContext` function that can automatically type `opts` with the necessary types.\r\n- I think all requests (queries and mutations) should get served from a single URL. The `path` can be added as an additional query parameter for queries and in the `body` for mutations. This would also simplify the Next/Express adapters (no need for a catchall API route).\r\n\r\n\r\nLess important:\r\n\r\nI think there should be a way of manually typing the input of a resolver without passing a validator into `input`. This is easy to do if the resolver functions had two parameters instead of one. I have this working on a local branch (type inference still works the same).\r\n\r\nI propose this syntax/convention:\r\n\r\n```ts\r\nconst router = trpc.router\u003CContext>().query('test', {\r\n resolve(input: number, req) {\r\n return input;\r\n },\r\n });\r\n```\r\n\r\nThe `req` variable above if of type `{ ctx: TContext, type: ProcedureType }`. This leaves the door open to future API expansion, as `req` can act like a catchall for any additional properties we want to pass into resolvers. ",[2954],{"name":2955,"color":2956},"๐ฌ discussion","4B318A",211,"API recommendations","2021-04-12T21:57:33Z","https://github.com/trpc/trpc/issues/211",0.7103875,{"description":2963,"labels":2964,"number":2966,"owner":2874,"repository":2874,"state":2912,"title":2967,"updated_at":2968,"url":2969,"score":2970},"### Provide environment information\n\n```\n System:\n OS: Windows 11 10.0.26100\n CPU: (20) x64 13th Gen Intel(R) Core(TM) i5-13600KF\n Memory: 42.13 GB / 63.81 GB\n Binaries:\n Node: 20.18.3 - C:\\Program Files\\nodejs\\node.EXE\n npm: 10.8.2 - C:\\Program Files\\nodejs\\npm.CMD\n Browsers:\n Edge: Chromium (133.0.3065.69)\n Internet Explorer: 11.0.26100.1882\n npmPackages:\n typescript: ^5.8.2 => 5.8.2\n```\n\n### Describe the bug\n\nThe output type file references `@trpc/server/dist/unstable-core-do-not-import` but it's not declared in `package.json`\n\n\n\nI can't get the corret inferenced types from type files.\n\n\n\nIt can be fixed with\n\nserver/package.json\n```diff\n\"exports\": {\n...\n+ \"./dist/*\": {\n+ \"import\": \"./dist/*.mjs\",\n+ \"require\": \"./dist/*.js\",\n+ \"default\": \"./dist/*.js\"\n+ }\n}\n```\nOr the import path should be changed to `@trpc/server/unstable-core-do-not-import` without the `dist` part since `unstable-core-do-not-import` is exported in `package.json`\n\n\n\n### Link to reproduction\n\nhttps://stackblitz.com/edit/vitejs-vite-g9btbcfw?file=dist%2Ftypes%2Fapp-router.d.ts&view=editor\n\n### To reproduce\n\n`npm run build` and check *dist/types/app-router.d.ts*\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!",[2965],{"name":2884,"color":2885},6644,"bug: Missing `dist` exports from package.json","2025-03-28T15:45:58Z","https://github.com/trpc/trpc/issues/6644",0.7124104,{"description":2972,"labels":2973,"number":2974,"owner":2874,"repository":2874,"state":2912,"title":2975,"updated_at":2976,"url":2977,"score":2978},"Did you have any plans for [Fastify](https://www.fastify.io/docs/latest/Middleware/) integration? Feels like its a perfect fix as its decently low level and all TS. \r\n\r\nI started writing a plugin but getting a little stuck in the types and the middie/express examples ported over (fastify has bridge support for express middleware ) don't seem to be working.\r\n\r\nfastTRPC\r\n```ts\r\nimport {\r\n AnyRouter,\r\n BaseOptions,\r\n CreateContextFn,\r\n CreateContextFnOptions,\r\n requestHandler,\r\n} from \"@trpc/server\";\r\nimport { FastifyInstance } from \"fastify\";\r\nimport fp from \"fastify-plugin\";\r\nimport { IncomingMessage, ServerResponse } from \"http\";\r\nimport { URL } from \"url\";\r\n\r\nexport type CreateHttpContextOptions = CreateContextFnOptions\u003C\r\n IncomingMessage,\r\n ServerResponse\r\n>;\r\n\r\nexport type CreateHttpContextFn\u003CTRouter extends AnyRouter> = CreateContextFn\u003C\r\n TRouter,\r\n IncomingMessage,\r\n ServerResponse\r\n>;\r\n\r\nexport interface CreateHttpHandlerOptions\u003CTRouter extends AnyRouter>\r\n extends BaseOptions\u003CTRouter, IncomingMessage> {\r\n prefix?: string;\r\n createContext: CreateHttpContextFn\u003CTRouter>;\r\n router: TRouter;\r\n}\r\n\r\nexport default fp(\r\n async function \u003CTRouter extends AnyRouter>(\r\n app: FastifyInstance,\r\n opts: CreateHttpHandlerOptions\u003CTRouter>\r\n ) {\r\n app.decorate(\"trpc\", opts);\r\n\r\n if (!opts.prefix) opts.prefix = \"/trpc\";\r\n console.log({ opts });\r\n\r\n app.all(opts.prefix, async (req, reply) => {\r\n const u = new URL(req.raw.url!);\r\n const path = u.pathname.substr(1);\r\n await requestHandler({\r\n ...opts,\r\n req: req.raw,\r\n res: reply.raw,\r\n path,\r\n });\r\n });\r\n },\r\n { fastify: \"3.x\", name: \"fastify-trpc\" }\r\n);\r\n```\r\ncalled using\r\n```ts\r\n const app = fastify();\r\n\r\n app.register(fastTRPC, {\r\n router: appRouter,\r\n createContext() {\r\n return {};\r\n },\r\n });\r\n\r\n app.listen(1234);\r\n```\r\n\r\nThis doesn't give any type errors but fails weirdly enough it seems to fail in the client. Never get to a breakpoint at first line in `app.all()` However the raw http example this is based on works fine.\r\n\r\n```ts\r\n\r\ntestrpc/node_modules/.pnpm/@trpc+client@7.1.0-alpha.1/node_modules/@trpc/client/dist/createTRPCClient-5ae1152d.cjs.dev.js:387\r\n return new TRPCClientError((_message = result.error.message) !== null && _message !== void 0 ? _message : '', _objectSpread(_objectSpread({}, opts), {}, {\r\n ^\r\nError: \r\n at Function.from (testrpc/node_modules/.pnpm/@trpc+client@7.1.0-alpha.1/node_modules/@trpc/client/dist/createTRPCClient-5ae1152d.cjs.dev.js:387:16)\r\n at testrpc/node_modules/.pnpm/@trpc+client@7.1.0-alpha.1/node_modules/@trpc/client/dist/createTRPCClient-5ae1152d.cjs.dev.js:331:58\r\n at processTicksAndRejections (node:internal/process/task_queues:96:5)\r\n```\r\n\r\nI don't know enough about the internals to really grok what's happening. would be nice if the npm version also exported the sourcemaps or ts code to step through.",[],524,"Fastify 3 support?","2022-10-04T18:07:30Z","https://github.com/trpc/trpc/issues/524",0.7144107,["Reactive",2980],{},["Set"],["ShallowReactive",2983],{"$fTRc1wZytZ_XrK4EfJfei_Sz-An4H4Yy6syhVxH_PVJc":-1,"$fJOfTELEqGXXX0_WR0tzUHg0lfa5zXUJL0eSoUyBdDWQ":-1},"/trpc/trpc/2030"]