trpc / trpc

πŸ§™β€β™€οΈ Move Fast and Break Nothing. End-to-end typesafe APIs made easy.
https://tRPC.io
MIT License
33.3k stars 1.18k forks source link

bug: vue-tsc errors #5723

Closed lacherogwu closed 3 weeks ago

lacherogwu commented 4 weeks ago

Provide environment information

 System:
    OS: macOS 14.4.1
    CPU: (14) arm64 Apple M3 Max
    Memory: 3.46 GB / 36.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.12.2 - ~/.nvm/versions/node/v20.12.2/bin/node
    npm: 10.7.0 - ~/.nvm/versions/node/v20.12.2/bin/npm
    pnpm: 9.1.0 - ~/.nvm/versions/node/v20.12.2/bin/pnpm
  Browsers:
    Chrome: 124.0.6367.203
    Safari: 17.4.1
  npmPackages:
    @trpc/client: ^10.45.2 => 10.45.2 
    typescript: ^5.2.2 => 5.4.5 

Describe the bug

When using vue-tsc for linting, I'm encountering errors from the node_modules within my server, as well as type errors related to the server. However, I'm only linting the client-side code.

here are example of the errors

> vue-tsc

../server/node_modules/amazon-sp-api/lib/typings/operations/catalogItems.ts:44:11 - error TS6196: 'IdentifierType' is declared but never used.

44 interface IdentifierType {
             ~~~~~~~~~~~~~~

../server/node_modules/amazon-sp-api/lib/typings/operations/catalogItems.ts:83:11 - error TS6196: 'AttributeSet' is declared but never used.

83 interface AttributeSet {
             ~~~~~~~~~~~~

../server/node_modules/amazon-sp-api/lib/typings/operations/catalogItems.ts:182:11 - error TS6196: 'Relationship' is declared but never used.

182 interface Relationship {
              ~~~~~~~~~~~~

../server/node_modules/amazon-sp-api/lib/typings/operations/catalogItems.ts:207:11 - error TS6196: 'SalesRank' is declared but never used.

207 interface SalesRank {
              ~~~~~~~~~

../server/trpc/router.ts:5:7 - error TS6133: 'a' is declared but its value is never read.

5 const a: string = "";
        ~

../server/trpc/router.ts:7:7 - error TS6133: 'spApi' is declared but its value is never read.

7 const spApi = new SellingPartner({
        ~~~~~

Found 6 errors in 2 files.

Errors  Files
     4  ../server/node_modules/amazon-sp-api/lib/typings/operations/catalogItems.ts:44
     2  ../server/trpc/router.ts:5

Link to reproduction

https://codesandbox.io/p/sandbox/hardcore-goldstine-vhhxrl

To reproduce

Have 2 folders

install trpc on server & client install amazon-sp-api or have any type check error, like unused variable or any else

run vue-tsc on client folder

Additional information

The reason of this error is because we need to import the AppRouter type from the server, which causing the vue-tsc typechecker to include stuff from the server

I've been searching extensively online but couldn't find a solution. I've tried various combinations with the tsconfig to exclude certain files, but nothing has worked so far.

πŸ‘¨β€πŸ‘§β€πŸ‘¦ Contributing

Funding

Fund with Polar

KATT commented 4 weeks ago

I think you just need skipLibCheck: true

https://www.totaltypescript.com/tsconfig-cheat-sheet

KATT commented 4 weeks ago

You will get errors from your server even if you're only type-checking your client, that works as designed.

lacherogwu commented 4 weeks ago

As you can see there is skipLibCheck: true in the tsconfig.json, that doesn't help. and If I would run tsc --noEmit on the server I wouldn't get these errors since I skipLibCheck: true

but still if I run vue-tsc on the client and because of this type import in the client from the server it would print these errors, even though it should ignore (i guess)

lacherogwu commented 4 weeks ago

but those who still have this problem and want quick-fix I wrote a small utility that helps to ignore those errors, you can check it here β†’ tsc-exclude

it works great πŸ˜‡

KATT commented 3 weeks ago

Hey there! :wave:

We appreciate the time you've taken to write this issue.

Unfortunately, we don't have the capacity to assist here as this issue does not seem to be related to tRPC itself.

Please feel free to re-open if you disagree or post in our help channels on Discord or in our GitHub Discussions.

lacherogwu commented 3 weeks ago

Yeah I feel you, thanks for your time, I might fill up an issue on typescript it might be the right place

github-actions[bot] commented 3 weeks ago

This issue has been locked because we are very unlikely to see comments on closed issues. If you are running into a similar issue, please create a new issue. Thank you.