https://github.com/katt/trpc-1025
https://github.com/katt/trpc-1025
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/katt/trpc-1025
- Owner: KATT
- Created: 2021-10-07T19:26:32.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-10-07T19:26:55.000Z (over 4 years ago)
- Last Synced: 2024-10-05T16:41:36.031Z (over 1 year ago)
- Size: 804 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# trpc-1025
Minimum reproducible case for https://github.com/trpc/trpc/discussions/1025.
An Express+TRPC server, and React+TRPC client. The client is bootstrapped and compiled using Vite. The monorepo uses Yarn v3, with PnP.
The issue is that when type checking the client (using `yarn tsc`), we observe errors relating to server-side typechecking.
# Reproducing
```bash
yarn
cd packages/client
yarn tsc
```
## Expected outcome
The client compiles.
## Actual outcome
```
../../.yarn/__virtual__/@trpc-react-virtual-f133f1ecd3/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.
../../.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'.
../../.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(2,18): error TS2307: Cannot find module 'http' or its corresponding type declarations.
../../.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.
../../.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'.
../../.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(2,18): error TS2307: Cannot find module 'http' or its corresponding type declarations.
../../.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'.
../../.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(3,33): error TS2307: Cannot find module 'url' or its corresponding type declarations.
../../.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'.
../../.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(2,30): error TS2307: Cannot find module 'events' or its corresponding type declarations.
../../.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(45,63): error TS2339: Property 'off' does not exist on type 'SubscriptionEventEmitter'.
```
# Running in development mode
In two separate windows, run:
```
cd packages/server
yarn dev
```
```
cd packages/client
yarn dev
```
Visit http://localhost:10010.
# Running in production mode
Run the following to build the client:
```
cd packages/client
yarn vite build
```
Note, the above skips the typechecking phase (which is where we encounter the error), but the compiled product _works as expected_, indicating the errors are strictly type-checking related.
Run the following to build the server:
```
cd packages/server
yarn build
```
Run the server as follows:
```
cd packages/server
yarn start
```
Visit http://localhost:10020.