Slow Typescript VSCode Intellisense
andrewdoro opened this issue · comments
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.
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
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
Can you try if something's like this works for you? juliusmarminge/acme-corp#225
I also have terrible vscode performance. It's crazy how deep these inferences get.
@juliusmarminge tried implementing the changes here, but I get the following errors from @acme/api. It also doesn't really improve something.
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.
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
Probably because Biome doesnt have rules that require type information.
@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
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 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
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.