TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

Typescript compiler hangs indefinitely

Open ThallesP opened this issue 10 months ago • 2 comments

🔎 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

ThallesP avatar Mar 14 '25 19:03 ThallesP

Hmmm it finally gave me an error message, guess thats a code error and not a Typescript issue, right?

Image

ThallesP avatar Mar 14 '25 19:03 ThallesP

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.

RyanCavanaugh avatar Mar 17 '25 20:03 RyanCavanaugh

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.

ThallesP avatar Jun 10 '25 18:06 ThallesP