Typescript compiler hangs indefinitely
🔎 Search Terms
"typescript hang","typescript hanging","tsc hanging","pnpm tsc hanging","tsc pnpm turborepo hanging","tsc stuck"
🕗 Version & Regression Information
I can't go back to an old TypeScript version as there are new packages I'm using that depend on newer TypeScript features. As far as I know, TypeScript 4.9.5 runs the build but it produces many errors, and for an unknown reason, if there's a TypeScript error, the compiler doesn't hang
⏯ Playground Link
No response
💻 Code
Use the following repository to reproduce:
- https://github.com/ThallesP/tsc-hangs-repro
You can do it by:
- pnpm install
- cd apps/repro && pnpm tsc
I included a .devcontainer configuration for easy testing or you could use Github Codespaces, it also hangs there.
🙁 Actual behavior
When running TSC inside the apps/repro it simply hangs. That also affects the LSP on Visual Studio Code.
EDIT: Seems like it completes after a long time (5+ minutes) for a single file.
🙂 Expected behavior
Well, it should compile.
Additional information about the issue
I attached a debugger and it seems to be stuck on a for loop inside the src/compiler/core.ts, probably a function outside of that is calling the contains over and over. I may be wrong tho.
https://github.com/user-attachments/assets/71c46218-5ef5-4855-879a-76edf338cec2
Hmmm it finally gave me an error message, guess thats a code error and not a Typescript issue, right?
We can look into this sooner with a more isolated repro or something narrowed down to a specific commit, but it's pretty time intensive to look at a whole repo with no other clues to go on.
After some more testing I found out that looping through imports somewhat crashed the tsc compiler, anyway we removed that and everything's smooth now.