httptoolkit / httptoolkit-ui

The UI of HTTP Toolkit
https://httptoolkit.com
GNU Affero General Public License v3.0
282 stars 106 forks source link

Avoid running type checking on library modules for perf #86

Closed mitchcapper closed 1 year ago

mitchcapper commented 1 year ago

https://www.typescriptlang.org/tsconfig#skipLibCheck

help the type checking startup speeds at the slight risk of type collisions.

pimterry commented 1 year ago

Sorry, but I don't want to enable this generally, so I'm going to close this.

Here I really do want the type safety that lib checking provides - notably without this the many custom .d.ts files we have (https://github.com/httptoolkit/httptoolkit-ui/tree/main/custom-typings) wouldn't be checked at all, and various other errors (e.g. incompatible library types) would silently result in broken types or implicit any types appearing unexpectedly. Incompatible types breaking like this has happened repeatedly in the past, and it would cause much bigger problems if it was invisible.

I'm sympathetic to TypeScript build time problems though. Can you share more about your setup, and the performance you're seeing on your machine?

When running with npm run start:web, Webpack should run the actual compilation & page reload completely in parallel, so typechecking won't block that directly. Of course despite that, it can still cause issues regardless if it uses up all your CPU & memory, or depending on how your IDE handles this.

I've just bumped TypeScript to 5.1.6 (the latest) on main, which includes quite a few performance fixes, and fixes some intellisense CPU usage bugs in anything using the TS language server (e.g. VS Code) that I've seen perf issues with myself. If you've got a second, I'd be interested to know if that helps in your case.

If there are still significant issues, we could do some investigation into the compilation at a lower level to look for root causes there - it'll never be instant, but this isn't a huge project, and it should definitely be possible to make it an acceptable speed to run in parallel without disabling checks completely.

mitchcapper commented 1 year ago

I was thinking it only didn't check calls within the libs themselves but not calls to the library. It is worthwhile to typecheck libs, initially thinking just at another time than every run. I will see if there is a way to add a run option that allows you to start without typechecks on them .

I did think it was part of what was blocking first request but from your comments that is not the case.

As for the why for this in the first place, just impatience and trying to speed up dev. Hot reload seems to work pretty well but there are plenty of times it throws old errors until I restart the server completely. Found myself doing that more often than I would like. It may only take 30 to 60 secs but when it's edit the reload the edit etc wanted see if there were any quick perf wins.

Too spoiled with vs hot reload in other languages ha.