Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slow Typescript VSCode Intellisense #924

Closed
3 tasks
andrewdoro opened this issue Mar 21, 2024 · 10 comments · Fixed by #932
Closed
3 tasks

Slow Typescript VSCode Intellisense #924

andrewdoro opened this issue Mar 21, 2024 · 10 comments · Fixed by #932

Comments

@andrewdoro
Copy link

Provide environment information

  System:
    OS: macOS 14.0
    CPU: (10) arm64 Apple M1 Max
    Memory: 1.03 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.1 - ~/Library/pnpm/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 10.2.4 - ~/Library/pnpm/npm
    pnpm: 8.14.1 - ~/Library/pnpm/pnpm
    bun: 1.0.31 - ~/.bun/bin/bun

Describe the bug

I need some help with handling this TS issue. Some things that I am not sure about:

  • Zod too slow for TS, I have a lot of validations also comming from drizzle-zod but also using .omit or .extend
  • Other dependecies like Stripe and Firebase might cause the slowdon
  • Should I split the trpc routers in smaller packages ?

Problem

Typescript Intellisense is very slow in my project. The project was boostrapped from this template. It currently has 17 trpc routers with logic from drizzle, zod, stripe and firebase. I don't think the current size should justify the slow ts.

bug.t3.mp4

I know this template uses incremental option in the tsconfig.json which should make sure that packages type inference are cached .cache, but it looks like when I use a trpc router it's always type-checking.

"incremental": true,

Investigation

I've also generated a trace from tsc. Seeing some stuff from @acme/db and @acme/auth but I am not sure if I am looking at the right things.
trace.json

Output from npx tsc --extendedDiagnostics for the nextjs app

Screenshot 2024-03-21 at 12 29 01

Link to reproduction

https://github.com/tabtick/tabtick

To reproduce

  • run pnpm install
  • press cmd + space
  • takes a few seconds to get intellisense

Additional information

No response

@juliusmarminge
Copy link
Member

Can you try if something's like this works for you? juliusmarminge/acme-corp#225

@dBianchii
Copy link
Contributor

I also have terrible vscode performance. It's crazy how deep these inferences get.

@andrewdoro
Copy link
Author

andrewdoro commented Mar 21, 2024

@juliusmarminge tried implementing the changes here, but I get the following errors from @acme/api. It also doesn't really improve something.
Screenshot 2024-03-21 at 14 24 31

https://github.com/tabtick/tabtick/pull/16/files

Do you think that this slowdown is caused by zod? Would it be an alternative to use typebox or another library for validation.

@estubmo
Copy link

estubmo commented Mar 22, 2024

I know it doesn't solve the issue for those who want to keep using ESlint and Prettier, but I moved to Biome.js and it's much, much more performant. There's even starter repo for it here: https://github.com/rajatsandeepsen/t3-turbo-biome

@juliusmarminge
Copy link
Member

Probably because Biome doesnt have rules that require type information.

@andrewdoro
Copy link
Author

@juliusmarminge implementing your recommendation seems to have helped a lot. I've split the @acme/api in two packages:

  • @acme/base where routes are defined and tsc -w command is running
  • @acme/api where the appRouter is created and then re-exported to client

I am still not sure if drizzle was the culprit, I am seeing .dts file of 3000 lines >.

//Also added declarationMap:true so I can still navigate directly to the router.
https://github.com/tabtick/tabtick/pull/16

@trevorpfiz
Copy link

I know it doesn't solve the issue for those who want to keep using ESlint and Prettier, but I moved to Biome.js and it's much, much more performant. There's even starter repo for it here: https://github.com/rajatsandeepsen/t3-turbo-biome

thinking about migrating. anything you are missing from ESLint+Prettier?

@juliusmarminge
Copy link
Member

I know it doesn't solve the issue for those who want to keep using ESlint and Prettier, but I moved to Biome.js and it's much, much more performant. There's even starter repo for it here: https://github.com/rajatsandeepsen/t3-turbo-biome

thinking about migrating. anything you are missing from ESLint+Prettier?

Typed linting

@ck-euan
Copy link

ck-euan commented May 8, 2024

I know it doesn't solve the issue for those who want to keep using ESlint and Prettier, but I moved to Biome.js and it's much, much more performant. There's even starter repo for it here: https://github.com/rajatsandeepsen/t3-turbo-biome

thinking about migrating. anything you are missing from ESLint+Prettier?

I just migrated today, it's a shame to lose the typed linting but I couldn't justify the performance hit any longer.

The linting rules it has are great - but you do lack things like the nextjs eslint plugin and tailwind class sorting which is a shame but I think a reasonable tradeoff for the performance gains.

@ya-s-u
Copy link

ya-s-u commented Oct 14, 2024

I've created a repository for my own.
https://github.com/ya-s-u/t3-turbo-biome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants