Any tips for Typescript slowness?
We successfully migrated from 9.x to 10 but are still seeing slow VS Code perf (10+ seconds to get any type info) are there any strategies we can use to minimize this?
9 Replies
GitHub
Performance · microsoft/TypeScript Wiki
TypeScript is a superset of JavaScript that compiles to clean JavaScript output. - Performance · microsoft/TypeScript Wiki
you can use e.g. turborepo to split up your codebase into different packages
Thank you
@Jack Fischer Just curious - are you using a lot of zod schemas that use
.extend
and .pick
and that sort of stuff? IE output schemas?
We've had some problems in the past and I think that contributed too it a lotInteresting, we're actually not. We're pretty casual users of zod. We do have other type intensive libraries though including EdgeDB. This likely has a lot to do with it but still interested in trpc-specific advice (like yours about zod)
ah cool thanks for the info, sounds like that would've contributed - always curious about learning more about typescript performance because it can be such a massive issue if it gets bad too bad as I've experienced first hand.
we were using Prisma as well, which I would think qualifies as being a typescript intensive library? I guess I don't really have a way of distinguishing whether it was zod or prisma contributing the most to the slow down. Wish there was like some "typescript score" or something that labelled which libraries have the biggest performance impact
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
don't really have a way of distinguishing whether it was zod or prisma contributing the most to the slow downThis is exactly our problem. In certain scenarios (for example writing a vanilla next.js endpoint not touching tRPC or zod, but involving edgedb) the editor suddenly becomes super fast. Lacking a way to determine why that is.
now that i think about it, it's not a performance problem but more like typescript goes nuts and gives random errors that stop showing when i close and open the file.In my experience this is also a performance thing where the random errors are simply old and it's struggling to complete a new round of static analysis. Much like closing/opening, if you leave it alone, it eventually resolves Something we tried that didn't work that I should have mentioned: splitting our 2.5k line tRPC router into multiple files. No impact, or possibly slower One more discovery: Setting
typescript.tsserver.maxTsServerMemory
higher in vscode helped a ton.ooooh that's really good to know @Jack Fischer , thank you