T
tRPC

Any tips for Typescript slowness?

Any tips for Typescript slowness?

JFJack Fischer12/19/2022
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?
AKAlex / KATT 🐱12/19/2022
https://github.com/microsoft/TypeScript/wiki/Performance#using-project-references you can use e.g. turborepo to split up your codebase into different packages
JFJack Fischer12/20/2022
Thank you
Iisaac_way12/22/2022
@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 lot
JFJack Fischer12/22/2022
Interesting, 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)
Iisaac_way12/23/2022
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
UUUnknown User12/23/2022
3 Messages Not Public
Sign In & Join Server To View
JFJack Fischer1/5/2023
don't really have a way of distinguishing whether it was zod or prisma contributing the most to the slow down
This 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.
Iisaac_way1/7/2023
ooooh that's really good to know @Jack Fischer , thank you

Looking for more? Join the community!

T
tRPC

Any tips for Typescript slowness?

Join Server
Recommended Posts
Change status of useMutation from 'success' back to 'idle'Hiya, I have a mutation for creating stuff that can run a few different ways on a page, and I want tIs it possible to call one procedure in another?I have multiple routers in my trpc server. For example userRouter (e.g. procedure: getUser) and postHandling Query Errors at Root of App (v9)I want to show an error toast on my `NextJS` frontend every time there is an error from `useQuery` itRPC Client webpack errorAs soon as I add the client part to my legacy app i get an error and Can't figure out what is wrong.cookies, headers and authenticationin express I can do something like `res.cookie("name", "value")` for example. alternatively I can dtrpc hook pattern. This works, but I’m not convinced…I want to call my route when a button is clicked and have access to isLoading, onError etc… I have iCatch TRPCError, ZoddError on the front-endi am throwing a TRPCError in a mutation. i dont understand how to catch this error in the OnError meimplicitly has type 'any' because it does not have a type annotation and is referenced directlyRunning into this error. I feel like it's some sort of infinite recursion issue, but not sure where Why do some examples create PrismaClient in context, and others don’tIs there a specific reason to do this or not to do this? I can imagine with the new Prisma extensionAppRouter type any?I am trying to use trpc in a Turbo repo and when I export the AppRouter on the server side it is thez.map() as an inputHi, I have ```ts z.map(z.string(), z.string()) ``` as an input, but when I try to pass the map as correct way to call TRPC inside a functioni want a user to be able to sign after they have a clicked a button but i get a hooks error. can anyuse tRPC for RPC calls instead of gRPCHi, I know that tRPC and gRPC are different things - despite the similar name. Nevertheless I woutRPC caching vs Vercel dynamic edge cachingWhat is the difference, or improvements, on Vercel's dynamic edge caching? tRPC server caching worksIgnore Errors from batch callsI have some of my routers throw helpful errors for the client to use in the error message object, buAny way to view headers in middleware?Middleware `input` doesn't seem to have it :/trying to cache api routesHello. I am using TRPC to make a site which integrates with a third party API. I need to add cachinPrisma+TRPC monorepoHey, so we have a monorepo with 3 backend services and 3 frontend services. It looks like the followcalling api endpoints from within a trpc api endpoint?Hey all. I have a series of api endpoints which may have to be reused across other api endpoints. ITRPC waiting until the query has completedHey. I've just found out about TRPC and I love it. However, I was wondering if there is a way to mak