Typescript errors when building #1025
-
First of all, thank you so much for building trpc, I'm finding it incredibly productive to work with. I have a monorepo (Yarn V3 with PnP) with express+trpc server and react+trpc client. When building (running $ yarn tsc
../../.yarn/__virtual__/@trpc-react-virtual-ad6238a3af/0/cache/@trpc-react-npm-9.8.1-katt-issue-1020-pin-2021-09-27-12-36-16.6-6f182fd388-e6c7db2e9e.zip/node_modules/@trpc/react/dist/declarations/src/createReactQueryHooks.d.ts:30:70 - error TS2307: Cannot find module 'packages/client/src/internals/TRPCClient' or its corresponding type declarations.
30 createClient: (opts: CreateTRPCClientOptions<TRouter>) => import("packages/client/src/internals/TRPCClient").TRPCClient<TRouter>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../.yarn/__virtual__/objection-virtual-f49c97575b/0/cache/objection-npm-3.0.0-alpha.4-8ca0cd8297-eec790bc78.zip/node_modules/objection/typings/objection/index.d.ts:1:23 - error TS2688: Cannot find type definition file for 'node'.
1 /// <reference types="node" />
~~~~
../../.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'.
1 /// <reference types="node" />
~~~~
../../.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.
3 import qs from 'qs';
~~~~
../../.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'.
1 /// <reference types="node" />
~~~~
../../.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'.
Type 'IncomingMessage' is not assignable to type '{ method?: string; query?: any; body?: unknown; }'.
Types of property 'method' are incompatible.
Type 'string | undefined' is not assignable to type 'string'.
Type 'undefined' is not assignable to type 'string'.
5 export declare type CreateHTTPHandlerOptions<TRouter extends AnyRouter> = NodeHTTPHandlerOptions<TRouter, http.IncomingMessage, http.ServerResponse>;
~~~~~~~~~~~~~~~~~~~~
../../.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
find type definition file for 'node'.
1 /// <reference types="node" />
~~~~
../../.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'.
1 /// <reference types="node" />
~~~~
../../.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'.
1 /// <reference types="node" />
~~~~
Found 9 errors. The one place I refer to the server from my client is in one file: import type { AppRPCRouter } from "@ski/server/src/api/router";
import { createReactQueryHooks } from "@trpc/react";
export const trpc = createReactQueryHooks<AppRPCRouter>(); I'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). How would I go about fixing this? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
I honestly have no idea how to debug this and it's a specific monorepo-issue; I'm pretty confident the root cause isn't tRPC, but if you create a reproduction-example I can have a look. As a reference though, here's a monorepo I have that is working with tRPC: https://github.com/KATT/zart |
Beta Was this translation helpful? Give feedback.
-
Created an issue from this discussion as it's worked on in #1140 Do conversation over at #1142 |
Beta Was this translation helpful? Give feedback.
Created an issue from this discussion as it's worked on in #1140
Do conversation over at #1142