\r\n ~~~~\r\n\r\n../../.yarn/cache/@trpc-server-npm-9.8.1-katt-issue-1020-pin-2021-09-27-12-36-16.6-cdb5a7a4be-e62c21a45b.zip/node_modules/@trpc/server/dist/declarations/src/adapters/node-http/types.d.ts:1:23 - error TS2688: Cannot find type definition file for 'node'.\r\n\r\n1 /// \u003Creference types=\"node\" />\r\n ~~~~\r\n\r\n../../.yarn/cache/@trpc-server-npm-9.8.1-katt-issue-1020-pin-2021-09-27-12-36-16.6-cdb5a7a4be-e62c21a45b.zip/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../../.yarn/cache/@trpc-server-npm-9.8.1-katt-issue-1020-pin-2021-09-27-12-36-16.6-cdb5a7a4be-e62c21a45b.zip/node_modules/@trpc/server/dist/declarations/src/adapters/standalone.d.ts:1:23 - error TS2688: Cannot find type definition file for 'node'.\r\n\r\n1 /// \u003Creference types=\"node\" />\r\n ~~~~\r\n\r\n../../.yarn/cache/@trpc-server-npm-9.8.1-katt-issue-1020-pin-2021-09-27-12-36-16.6-cdb5a7a4be-e62c21a45b.zip/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; }'.\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\n../../.yarn/cache/@trpc-server-npm-9.8.1-katt-issue-1020-pin-2021-09-27-12-36-16.6-cdb5a7a4be-e62c21a45b.zip/node_modules/@trpc/server/dist/declarations/src/http/internals/types.d.ts:1:23 - error TS2688: Cannot \r\nfind type definition file for 'node'.\r\n\r\n1 /// \u003Creference types=\"node\" />\r\n ~~~~\r\n\r\n../../.yarn/cache/@trpc-server-npm-9.8.1-katt-issue-1020-pin-2021-09-27-12-36-16.6-cdb5a7a4be-e62c21a45b.zip/node_modules/@trpc/server/dist/declarations/src/subscription.d.ts:1:23 - error TS2688: Cannot find type definition file for 'node'.\r\n\r\n1 /// \u003Creference types=\"node\" />\r\n ~~~~\r\n\r\n../../.yarn/cache/tarn-npm-3.0.1-afc495be8f-c7347ce8c4.zip/node_modules/tarn/dist/Pool.d.ts:1:23 - error TS2688: Cannot find type definition file for 'node'.\r\n\r\n1 /// \u003Creference types=\"node\" />\r\n ~~~~\r\n\r\n\r\nFound 9 errors.\r\n```\r\n\r\nThe one place I refer to the server from my client is in one file:\r\n\r\n```ts\r\nimport type { AppRPCRouter } from \"@ski/server/src/api/router\";\r\nimport { createReactQueryHooks } from \"@trpc/react\";\r\n\r\nexport const trpc = createReactQueryHooks\u003CAppRPCRouter>();\r\n```\r\n\r\nI'm not sure what's going on here, as it looks like typescript is trying to build (or typecheck) the server files, but then doesn't have the correct local packages to be able to do this (objection is the ORM I'm using on the server).\r\n\r\nHow would I go about fixing this?\r\n\r\nThanks!",[],1022,"Typescript errors when building","2022-10-04T18:08:08Z","https://github.com/trpc/trpc/issues/1022",0.6932602,{"description":2906,"labels":2907,"number":2917,"owner":2853,"repository":2853,"state":2892,"title":2918,"updated_at":2919,"url":2920,"score":2921},"While working on a project with tRPC (based on the `fastify-server` example), I came across a type error while attempting to build the project.\r\n```\r\nnode_modules/@trpc/client/dist/declarations/src/TRPCClientError.d.ts:13:14 - error TS2416: Property 'cause' in type 'TRPCClientError\u003CTRouter>' is not assignable to the same property in base type 'Error'.\r\n Type 'Maybe\u003CError>' is not assignable to type 'Error | undefined'.\r\n Type 'null' is not assignable to type 'Error | undefined'.\r\n\r\n13 readonly cause: Maybe\u003CError>;\r\n ~~~~~\r\n\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\nI managed to figure out what causes the bug: There is a breaking change in `typescript@4.6.2`, [this one](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-6.html#object-rests-drop-unspreadable-members-from-generic-objects) I believe \r\nThrough more testing, I also figured out a few workarounds: \r\n- Use `typescript@4.5.5`\r\n- Set the `target` in `tsconfig.json` to `ES2021`\r\n- Set the `target` in `tsconfig.json` to `ES6` \r\n \r\nI was going to file a PR, but then I wasn't sure exactly what needs to be fixed(?). Is this a bug that needs fixing within tRPC itself? Should there be a warning in the docs? Should the examples use the aforementioned `tsconfig` workaround? Should the entire repo use the `tsconfig` workaround? \r\n \r\nI am very willing to help with a fix but I need some insight. ",[2908,2911,2914],{"name":2909,"color":2910},"@trpc/server","9BE78E",{"name":2912,"color":2913},"@trpc/client","6095C2",{"name":2915,"color":2916},"🔎 needs more investigation/info","d4c5f9",2292,"Potential for future type error in TRPCError & TRPCClientError","2022-09-29T21:24:11Z","https://github.com/trpc/trpc/issues/2292",0.6979101,{"description":2923,"labels":2924,"number":2925,"owner":2853,"repository":2853,"state":2892,"title":2926,"updated_at":2927,"url":2928,"score":2929},"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.70040905,{"description":2931,"labels":2932,"number":2934,"owner":2853,"repository":2853,"state":2892,"title":2935,"updated_at":2936,"url":2937,"score":2938},"### Provide environment information\n\n System:\r\n OS: macOS 13.2.1\r\n CPU: (10) arm64 Apple M1 Pro\r\n Memory: 55.72 MB / 16.00 GB\r\n Shell: 5.8.1 - /bin/zsh\r\n Binaries:\r\n Node: 16.19.1 - ~/.nvm/versions/node/v16.19.1/bin/node\r\n npm: 8.19.3 - ~/.nvm/versions/node/v16.19.1/bin/npm\r\n Browsers:\r\n Brave Browser: 111.1.49.128\r\n Chrome: 112.0.5615.121\r\n Safari: 16.3\r\n npmPackages:\r\n @trpc/server: 10.20.0 => 10.20.0 \r\n typescript: ^4.9.4 => 4.9.4 \n\n### Describe the bug\n\nI stumbled upon this recently with a third party library. The third party client throws objects that are not an instance of `Error`\r\nie: \r\n```typescript\r\nthrow { message: 'Something went wrong', name: 'ApiError', code: 403 }\r\n```\r\nWhen that happens, the whole object get swallowed by trpc and the output becomes\r\n```\r\ncode: 'INTERNAL_SERVER_ERROR',\r\nhttpStatus: 500,\r\nstack: 'Error: Unknown error\\n' +\r\n ' at getErrorFromUnknown', \r\n // ...\r\n```\r\nWith no trace at all of the original object being thrown, which makes investigation really hard as to why this 500 error happened, as there's no stacktrace and no info about the original error at all\r\n\r\nWhile I know this is bad practice to throw an object that is not an instance of an error, I feel like there's a non trivial chance of this happening in the wild with libraries (the one in this case is a decently popular one, 1.2k stars and 1 million weekly downloads)\r\n\r\nI tested with throwing a string, and this works correctly\r\nie: `throw 'Custom error message'` , the problem seems to only happen with object that do not instantiate `Error`\r\n\r\nI feel like if the shape of the thrown object is not an error but has similar properties (\"message\", maybe \"name\" and \"code\"), this should be mirrored to the error TRPC generates?\n\n### Link to reproduction\n\nhttps://stackblitz.com/edit/github-s8joae?file=src/pages/api/trpc/[trpc].ts\n\n### To reproduce\n\nMake any endpoint `throw { message: 'Custom error message', name: 'Third Party API error' };` and see what gets logged on the server\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!",[2933],{"name":2909,"color":2910},4217,"bug: Throwing an object that is not an instance of Error get swallowed","2023-05-04T12:02:09Z","https://github.com/trpc/trpc/issues/4217",0.70213825,{"description":2940,"labels":2941,"number":2945,"owner":2853,"repository":2853,"state":2892,"title":2946,"updated_at":2947,"url":2948,"score":2949},"### Provide environment information\r\n\r\n```\r\nSystem:\r\n OS: macOS 13.2.1\r\n CPU: (10) arm64 Apple M1 Max\r\n Memory: 3.48 GB / 32.00 GB\r\n Shell: 5.8.1 - /bin/zsh\r\n Binaries:\r\n Node: 19.8.1 - ~/.asdf/installs/nodejs/19.8.1/bin/node\r\n Yarn: 1.22.19 - ~/.asdf/installs/nodejs/19.8.1/bin/yarn\r\n npm: 9.5.1 - ~/.asdf/plugins/nodejs/shims/npm\r\n Browsers:\r\n Brave Browser: 113.1.51.114\r\n Safari: 16.3\r\n npmPackages:\r\n @trpc/server: ^10.28.0 => 10.28.0\r\n react: ^18.2.0 => 18.2.0\r\n typescript: ^5.0.4 => 5.0.4\r\n```\r\n\r\n### Describe the bug\r\n\r\n```\r\nnode_modules/.pnpm/@trpc+server@10.28.0/node_modules/@trpc/server/src/core/internals/procedureBuilder.ts:404:20 - error TS2339: Property 'error' does not exist on type 'MiddlewareResult\u003Cany>'.\r\n Property 'error' does not exist on type 'MiddlewareOKResult\u003Cany>'.\r\n\r\n404 throw result.error;\r\n```\r\n\r\n```\r\nnode_modules/.pnpm/@trpc+server@10.28.0/node_modules/@trpc/server/src/deprecated/internals/procedure.ts:244:20 - error TS2339: Property 'error' does not exist on type 'MiddlewareResult\u003Cany>'.\r\n Property 'error' does not exist on type 'MiddlewareOKResult\u003Cany>'.\r\n\r\n244 throw result.error;\r\n```\r\n\r\n### To reproduce\r\n\r\nWhen trying to build via `tsc`, I receive the following error: `Property 'error' does not exist on type 'MiddlewareOKResult\u003Cany>'.`\r\n\r\n### Additional information\r\nAdding `\"skipLibCheck\": true,` doesn't work.\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!\r\n\r\n\r\n\n\n\u003Csub>[T-80](https://linear.app/trpc/issue/T-80/bug-ts2339-error-on-middlewareokresultany)\u003C/sub>",[2942],{"name":2943,"color":2944},"⏮ needs reproduction","000055",4426,"bug: TS2339 error on MiddlewareOKResult\u003Cany>","2023-06-14T18:01:59Z","https://github.com/trpc/trpc/issues/4426",0.70328814,{"description":2951,"labels":2952,"number":2953,"owner":2853,"repository":2853,"state":2892,"title":2954,"updated_at":2894,"url":2955,"score":2956},"Getting an error when compiling a project that uses trpc, here's the error, deps and tsconfig.json\r\n\r\n### Error\r\n```\r\n../../node_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#22 12.52 Type 'unknown' is not assignable to type 'Error | undefined'.\r\n``` \r\n\r\n### relevant deps\r\n```\r\n\"dependencies\": {\r\n \"@trpc/server\": \"^9.22.0\"\r\n },\r\n \"devDependencies\": {\r\n \"@types/node\": \"17.0.23\",\r\n \"typescript\": \"4.6.3\"\r\n }\r\n```\r\n\r\n### tsconfig\r\n```\r\n{\r\n \"compilerOptions\": {\r\n \"target\": \"esnext\",\r\n \"allowJs\": true,\r\n \"strict\": true,\r\n \"strictNullChecks\": true,\r\n \"forceConsistentCasingInFileNames\": true,\r\n \"esModuleInterop\": false,\r\n \"allowSyntheticDefaultImports\": true,\r\n \"moduleResolution\": \"node\",\r\n \"module\": \"CommonJS\",\r\n \"resolveJsonModule\": true,\r\n \"incremental\": true\r\n },\r\n \"include\": [\"**/*.ts\", \"**/*.d.ts\", \"**/*.tsx\"],\r\n \"exclude\": [\"node_modules\"]\r\n}\r\n```",[],1927,"Error compiling trpc: TRPCError.d.ts(7,14): error TS2416","https://github.com/trpc/trpc/issues/1927",0.70550317,["Reactive",2958],{},["Set"],["ShallowReactive",2961],{"$fTRc1wZytZ_XrK4EfJfei_Sz-An4H4Yy6syhVxH_PVJc":-1,"$fMoSyyJ0SMZPkcZu6UyWN7Q_x0IeVIuDrfqN1AJyB4QM":-1},"/trpc/trpc-openapi/277"]