\n\n### Link to reproduction\n\n---\n\n### To reproduce\n\n---\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!",[2903],{"name":2868,"color":2869},6737,"bug: cannot narrow input types of `useMutation(trpc...).mutate(INPUT)` - cannot overwrite `mutationoptions.mutationFn` (`@trpc/tanstack-react-query`)","2025-05-01T18:59:50Z","https://github.com/trpc/trpc/issues/6737",0.66244143,{"description":2910,"labels":2911,"number":2912,"owner":2871,"repository":2871,"state":2881,"title":2913,"updated_at":2914,"url":2915,"score":2916},"### Provide environment information\n\nOS: macOS 13.0\r\nCPU: (8) x64 Apple M1\r\nMemory: 16.57 MB / 16.00 GB\r\nShell: 5.5.1 - /usr/local/bin/zsh\r\nBinaries:\r\nNode: 14.18.3 - ~/.nvm/versions/node/v14.18.3/bin/node\r\nYarn: 1.22.19 - ~/.nvm/versions/node/v14.18.3/bin/yarn\r\nnpm: 8.13.1 - ~/.nvm/versions/node/v14.18.3/bin/npm\r\nBrowsers:\r\nBrave Browser: 87.1.18.75\r\nChrome: 107.0.5304.110\r\nFirefox: 105.0.3\r\nFirefox Developer Edition: 76.0\r\nSafari Technology Preview: 16.4\r\n\n\n### Describe the bug\n\nI don't really know how this type checking really works but if somehow the client repo has different trpc version than the server ones, if I start the client side (e.g. nuxt) it will throw an error.\r\n\r\nError stacktrace\r\n```\r\nERROR ERROR in client.ts:5:45 05:06:06\r\nTS2344: Type 'Router\u003C{ _config: RootConfig\u003C{ ctx: any; meta: {}; errorShape: DefaultErrorShape; transformer: DefaultDataTransformer; }>; router: true; ... 5 more ...; isDev: boolean; }> & { ...; }' does not satisfy the constraint 'Router\u003CAnyRouterDef\u003CAnyRootConfig, any>>'.\r\nThe types returned by 'createCaller(...)' are incompatible between these types.\r\nType '{ query: inferHandlerFn\u003C{}>; mutation: inferHandlerFn\u003C{}>; subscription: inferHandlerFn\u003C{}>; } & DecoratedProcedureRecord\u003C{ exportReport: BuildProcedure\u003C\"query\", { ...; }, { ...; }>; }>' is not assignable to type '{ query: inferHandlerFn; mutation: inferHandlerFn; subscription: inferHandlerFn; } & DecoratedProcedureRecord'.\r\nType '{ query: inferHandlerFn\u003C{}>; mutation: inferHandlerFn\u003C{}>; subscription: inferHandlerFn\u003C{}>; } & DecoratedProcedureRecord\u003C{ exportReport: BuildProcedure\u003C\"query\", { ...; }, { ...; }>; }>' is not assignable to type '{ query: inferHandlerFn; mutation: inferHandlerFn; subscription: inferHandlerFn; }'.\r\nTypes of property 'query' are incompatible.\r\nType 'inferHandlerFn\u003C{}>' is not assignable to type 'inferHandlerFn'.\r\nTypes of parameters 'path' and 'path' are incompatible.\r\nType 'TPath' is not assignable to type 'never'.\r\nType 'string' is not assignable to type 'never'.\r\n```\r\n\r\nIf I understand it correctly, type checking in this case is probably inferred from the compilation time, how is the version of another repo that host the server app router code has to do with this and invalidate the inference? I'm really confused.\n\n### Link to reproduction\n\n123\n\n### To reproduce\n\nI have two repos, frontend-code and backend-code\r\n\r\nfrontend-code has yarn.lock `trpc/client 10.0.0-rc.8`, `trpc/client 10.0.0-rc.8`\r\nbackend-code has yarn.lock `trpc/client 10.0.0-rc.7`\r\n\r\nThe code that throw an error from (this runs in a nuxt project as a plugin)\r\n```\r\nimport Vue from 'vue'\r\nimport { createTRPCProxyClient, httpBatchLink } from '@trpc/client';\r\nimport type { AppRouter } from '../../../backend-code/server/_app';\r\n\r\nexport const client = createTRPCProxyClient\u003CAppRouter>({\r\n links: [\r\n httpBatchLink({\r\n url: process.env.TRPC_URL || '',\r\n fetch(url, options) {\r\n return fetch(url, {\r\n ...options,\r\n credentials: 'omit', // cors\r\n });\r\n },\r\n }),\r\n ],\r\n});\r\n```\r\n\r\nCode in ../../../backend-code/server/_app\r\n```\r\nimport { mergeRouters } from './trpc';\r\nimport { exportRouter } from './routers/report' // (a typical trpc router)\r\n \r\nexport const appRouter = exportRouter;\r\n \r\n// Export **type** of a router\r\nexport type AppRouter = typeof appRouter;\r\n```\r\n\r\n\r\nError stacktrace\r\n```\r\nERROR ERROR in client.ts:5:45 05:06:06\r\nTS2344: Type 'Router\u003C{ _config: RootConfig\u003C{ ctx: any; meta: {}; errorShape: DefaultErrorShape; transformer: DefaultDataTransformer; }>; router: true; ... 5 more ...; isDev: boolean; }> & { ...; }' does not satisfy the constraint 'Router\u003CAnyRouterDef\u003CAnyRootConfig, any>>'.\r\nThe types returned by 'createCaller(...)' are incompatible between these types.\r\nType '{ query: inferHandlerFn\u003C{}>; mutation: inferHandlerFn\u003C{}>; subscription: inferHandlerFn\u003C{}>; } & DecoratedProcedureRecord\u003C{ exportReport: BuildProcedure\u003C\"query\", { ...; }, { ...; }>; }>' is not assignable to type '{ query: inferHandlerFn; mutation: inferHandlerFn; subscription: inferHandlerFn; } & DecoratedProcedureRecord'.\r\nType '{ query: inferHandlerFn\u003C{}>; mutation: inferHandlerFn\u003C{}>; subscription: inferHandlerFn\u003C{}>; } & DecoratedProcedureRecord\u003C{ exportReport: BuildProcedure\u003C\"query\", { ...; }, { ...; }>; }>' is not assignable to type '{ query: inferHandlerFn; mutation: inferHandlerFn; subscription: inferHandlerFn; }'.\r\nTypes of property 'query' are incompatible.\r\nType 'inferHandlerFn\u003C{}>' is not assignable to type 'inferHandlerFn'.\r\nTypes of parameters 'path' and 'path' are incompatible.\r\nType 'TPath' is not assignable to type 'never'.\r\nType 'string' is not assignable to type 'never'.\r\n```\r\n\r\nIf I understand it correctly, type checking in this case is probably inferred from the compilation time, how is the version of another repo that host the server app router code has to do with this and invalidate the inference? I'm really confused.\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!",[],3206,"bug: if trpc package version is different between server and client code it will throw an error","2022-11-20T14:06:29Z","https://github.com/trpc/trpc/issues/3206",0.6736162,{"description":2918,"labels":2919,"number":2921,"owner":2871,"repository":2871,"state":2881,"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":2890,"color":2891},1904,"Type Errors","2022-10-04T12:02:52Z","https://github.com/trpc/trpc/issues/1904",0.6747835,{"description":2927,"labels":2928,"number":2932,"owner":2871,"repository":2871,"state":2881,"title":2933,"updated_at":2934,"url":2935,"score":2936},"### Describe the feature you'd like to request\r\n\r\na feature where you define Query and Mutation in the same procedure path\r\n\r\nthis might benefit reducing the paths you'll have to create E.g. profile.view, profile.update\r\n\r\n```ts\r\nconst appRouter = server.router({\r\n profile: server.router({\r\n view: ...,\r\n update: ...\r\n })\r\n})\r\n```\r\n\r\n### Describe the solution you'd like to see\r\n\r\n```ts \r\n// server\r\nconst profileRouter = server.procedure\r\n .mutation(z.object({ ... }), async ({ ctx, input }) => {\r\n // update profile\r\n })\r\n .query(z.object({ ... }), async ({ ctx, input }) => {\r\n // find profile\r\n })\r\n\r\n// client\r\nconst query = trpc.profile.useQuery({...}, {...})\r\nconst mutation = trpc.profile.useMutation({...})\r\n```\r\n\r\n### Describe alternate solutions\r\n\r\n```ts\r\nconst appRouter = server.router({\r\n profile: server.procedure\r\n .mutation({\r\n meta: {}, // idk about this\r\n input: z.object({ ... }),\r\n resolve: async ({ ctx, input }) => {\r\n // update profile\r\n }\r\n })\r\n .query({\r\n meta: {}, // idk about this\r\n input: z.object({ ... }),\r\n resolve: async ({ ctx, input }) => {\r\n // find profile\r\n }\r\n })\r\n})\r\n ```\r\n\r\n### Additional information\r\n\r\nI don't know if the implementation behind this or if this doesn't follow the standards of RPCs or if this is possible without changing many things.\r\njust an Idea I thought I could share.\r\n\r\nmaybe v11 🤷♂️\r\n\r\n\r\n### 👨👧👦 Contributing\r\n\r\n- [ ] 🙋♂️ Yes, I'd be down to file a PR implementing this feature!",[2929],{"name":2930,"color":2931},"wontfix","ffffff",3319,"feat: Query and Mutation at the same level","2022-12-15T18:01:55Z","https://github.com/trpc/trpc/issues/3319",0.67816436,{"description":2938,"labels":2939,"number":2940,"owner":2871,"repository":2871,"state":2881,"title":2941,"updated_at":2942,"url":2943,"score":2944},"Hi @KATT, \r\nThank you for this great library. \r\n\r\nI am reporting that the server types need updates after the latest typescript release (4.6): \r\n\r\n```bash\r\nnode_modules/@trpc/server/dist/declarations/src/TRPCError.d.ts:7:14 - error TS2416: Property 'cause' in type 'TRPCError' is not assignable to the same property in base type 'Error'.\r\n Type 'unknown' is not assignable to type 'Error | undefined'.\r\n\r\n7 readonly cause?: unknown;\r\n ~~~~~\r\n\r\n\r\nFound 1 error in node_modules/@trpc/server/dist/declarations/src/TRPCError.d.ts:7\r\n```\r\n\r\n\r\n\r\nBest regards \r\n",[],1588,"Type error in @trpc/server with TS 4.6","2022-10-04T12:03:04Z","https://github.com/trpc/trpc/issues/1588",0.68050903,{"description":2946,"labels":2947,"number":2954,"owner":2871,"repository":2871,"state":2881,"title":2955,"updated_at":2956,"url":2957,"score":2958},"### Provide environment information\r\n\r\n```\r\n System:\r\n OS: Linux 5.15 Manjaro Linux\r\n CPU: (12) x64 AMD Ryzen 5 4600H with Radeon Graphics\r\n Memory: 7.99 GB / 15.05 GB\r\n Container: Yes\r\n Shell: 5.1.16 - /bin/bash\r\n Binaries:\r\n Node: 16.15.0 - ~/.nvm/versions/node/v16.15.0/bin/node\r\n Yarn: 1.22.18 - ~/.nvm/versions/node/v16.15.0/bin/yarn\r\n npm: 8.5.5 - ~/.nvm/versions/node/v16.15.0/bin/npm\r\n Browsers:\r\n Firefox: 105.0.3\r\n npmPackages:\r\n @tanstack/react-query: ^4.13.0 => 4.13.0 \r\n @trpc/client: ^10.0.0-rc.1 => 10.0.0-rc.1 \r\n @trpc/react-query: ^10.0.0-rc.1 => 10.0.0-rc.1 \r\n @trpc/server: ^10.0.0-rc.1 => 10.0.0-rc.1 \r\n react: 17.0.1 => 17.0.1 \r\n typescript: ~4.3.5 => 4.3.5 \r\n```\r\n\r\n### Describe the bug\r\n\r\nIt is currently not possible to run `@trpc/react-query` with TypeScript versions older than 4.5 ([see TS changelog](https://devblogs.microsoft.com/typescript/announcing-typescript-4-5/#type-on-import-names)). Upgrading to 4.5 fixes this issue.\r\n\r\nThe following is thrown when running `tsc` on TS 4.3:\r\n\r\n\r\n\r\n### Link to reproduction\r\n\r\nhttps://stackblitz.com/edit/github-pe2txe?file=src/main.ts\r\n\r\n### To reproduce\r\n\r\n1. Open the reproduction link\r\n2. Run `npm run tsc`\r\n3. See error\r\n\r\n### Additional information\r\n\r\n_No response_\r\n\r\n### 👨👧👦 Contributing\r\n\r\n- [X] 🙋♂️ Yes, I'd be down to file a PR fixing this bug!",[2948,2951],{"name":2949,"color":2950},"📚 documentation / examples","0075ca",{"name":2952,"color":2953},"👻 invalid","e4e669",3088,"bug: @trpc/react-query breaks in typescript \u003C 4.5","2022-12-09T12:02:03Z","https://github.com/trpc/trpc/issues/3088",0.6836635,{"description":2960,"labels":2961,"number":2965,"owner":2871,"repository":2871,"state":2881,"title":2966,"updated_at":2967,"url":2968,"score":2969},"Here's my router code.\r\n\r\n```ts\r\nimport { PrismaClient } from '@prisma/client'\r\nimport * as trpc from '@trpc/server'\r\nimport * as trpcNext from '@trpc/server/adapters/next'\r\nimport z from 'zod'\r\n\r\nconst prisma = new PrismaClient()\r\n\r\nconst appRouter = trpc.router().query('login', {\r\n input: z.object({\r\n email: z.string(),\r\n password: z.string(),\r\n }),\r\n async resolve({ input }) {\r\n return prisma.user.findFirst({\r\n where: {\r\n email: input.email,\r\n password: input.password,\r\n },\r\n })\r\n },\r\n})\r\n```\r\n\r\nand here's it's type:\r\n```ts\r\nconst appRouter: Router\u003Cunknown, unknown, {}, Record\u003C\"login\", Procedure\u003Cunknown, unknown, {}, undefined, undefined, User, unknown, User>>, {}, {}, trpc.DefaultErrorShape>\r\n```\r\n\r\nAs you can see, it doesn't infer the type of request input which is\r\n```ts\r\n{\r\n email: string\r\n password: string\r\n}\r\n```\r\nand instead, it's just `undefined`.\r\n\r\nWhat am I doing wrong here?",[2962],{"name":2963,"color":2964},"⏮ needs reproduction","000055",2072,"Router doesn't infer types properly","2022-07-02T04:14:40Z","https://github.com/trpc/trpc/issues/2072",0.68384045,["Reactive",2971],{},["Set"],["ShallowReactive",2974],{"$fTRc1wZytZ_XrK4EfJfei_Sz-An4H4Yy6syhVxH_PVJc":-1,"$fm1dmr3_rsTFOVbYliQuu2QiKjYvu4G-zfjFIuurkMUM":-1},"/trpc/trpc/510"]