After having issues with typescript crashing quite often inside vscode, I wanted to find out how I can optimize my types and make them simpler. After watching Matt Pocock's & Aleksandra Sikora video (https://www.youtube.com/watch?v=ZL3z1oBZntk), a few of the main points that were talked about, was lowering instantiations / better caching and how to achieve that.
Now a few day later, I have managed to drastically lower instantiations of my somewhat poorly implemented (typing wise) typesafe api router. To talk numbers: Instantiations: 1.85m
1.2m and different caches would vary in size during optimizing and cleaning up but end up around the same size.
My main problem is that my expectation were not met at all. After a significant 35% reduction of instantiations I see no meaningful performance gains. Around 0.2-0.3s from a total of 6.5-7 seconds, and that's a huge maybe because the total time would vary a lot (probably due to the nature of JS and my 700€ laptop).
So my question, to anyone who can answer, am I blind to something obvious or am I missing something completely? If you want me to share my code/types just tell me and I'll link my repo.
Side note: On the left of the image is the optimized version and on the right one the unoptimized.
Become a TypeScript Wizard with my free beginners TypeScript Course:
https://www.totaltypescript.com/tutorials/beginners-typescript
Follow Matt on Twitter
https://twitter.com/mattpocockuk
Join the Discord: