DEV Community

csm for Necoz

Posted on Edited on

How to Crash tsc

Unchecked response files cause infinite loops

If you are a TypeScript developer and like the language a lot, but don't like the compiler errors, then I got a secret spell for you.
The spell which will confuse the compiler to crash 😄

Are you familiar with Response files?

Yeah, this one! I know, we rarely use it.
When we have a lot of options to provide to the compiler, we put them in a file and give it to the compiler like this:

tsc @hello.txt
🔥 ข่าวด่วน: necoz/how to crash tsc j - Kapook Update 2025 🔥 ข่าวด่วน: necoz/how to crash tsc j - Kapook Update 2025

Then, the compiler reads the options from that file and runs them as if they were provided on the command-line.

You can provide as many response files as you want.

So, what is the spell?

Here is the recipe:

  • Create two files: 1.txt and 2.txt.
  • Fill them with this:

1.txt:

@2.txt
🔥 ข่าวด่วน: necoz/how to crash tsc j - Kapook Update 2025 🔥 ข่าวด่วน: necoz/how to crash tsc j - Kapook Update 2025

2.txt

@1.txt
🔥 ข่าวด่วน: necoz/how to crash tsc j - Kapook Update 2025 🔥 ข่าวด่วน: necoz/how to crash tsc j - Kapook Update 2025
  • Run the spell, I mean give the file to tsc:
tsc @1.txt
🔥 ข่าวด่วน: necoz/how to crash tsc j - Kapook Update 2025 🔥 ข่าวด่วน: necoz/how to crash tsc j - Kapook Update 2025

(Full screen the terminal before running!)

Wait for it, wait for it, then, after roughly 20 seconds, boom!

What happened?

Simple, the compiler read the 1.txt file, it contained an option, that is another response file 2.txt.
So, it ran the option as regular option, so opened the 2.txt file. And, since 2.txt file has 1.txt file as content, it became a loop.
So it keeps opening the two files forever!

Technically, its called Circular reference.
Mostly, its a rare case, but it should be handled by the compiler.
If you are a TypeScipt developer, you can make a PR for this 😉

Top comments (14)

🔥 ข่าวด่วน: necoz/how to crash tsc j - Kapook Update 2025
 
nyaomaru profile image
nyaomaru Necoz • • Edited

Haha, I love this! 😹

Circular dependencies can be such a headache in real-world projects too, especially with barrel exports! Thankfully, I don't run into them much these days when coding with AI. 🙌

I couldn't resist trying your little spell, and guess what? It worked! 💥

I managed to reproduce the crash with TypeScript 7.0.2! 💚

Just one tiny thing I noticed! I think the example in the article might be missing the @ prefix in both files.

Here's what worked for me 👇

1.txt: @2.txt

2.txt: @1.txt

Without the @, TypeScript treats them as regular source files and reports TS6054 instead.

Might be worth a quick update so everyone can enjoy the magic too! 🪄😸

Thanks for sharing this fun experiment! I had a good laugh! 💚

Picked as gem
🔥 ข่าวด่วน: necoz/how to crash tsc j - Kapook Update 2025
 
csm18 profile image
csm Necoz • • Edited

Oh, I forgot the @.
Thanks for finding that small detail without which the spell will not work 😄
I will update it in the article 😸👍🏻

🔥 ข่าวด่วน: necoz/how to crash tsc j - Kapook Update 2025
 
effessdev profile image
EffessDev Necoz •

🙀 Coooool!!!

🔥 ข่าวด่วน: necoz/how to crash tsc j - Kapook Update 2025
 
effessdev profile image
EffessDev Necoz •

Oh, this was you, @csm18! I thought it was @nyaomaru when I saw Necoz, but I was thinking why @nyaomaru is writing posts like this. Only you can write posts like these 👏👏👏

🔥 ข่าวด่วน: necoz/how to crash tsc j - Kapook Update 2025
 
nyaomaru profile image
nyaomaru Necoz •

Great article! 😸

🔥 ข่าวด่วน: necoz/how to crash tsc j - Kapook Update 2025
 
csm18 profile image
csm Necoz •

Thank you bro 😊
Necoz started with Typscript and @nyaomaru loves Typescript, so I thought this would be the right place to post 😄

🔥 ข่าวด่วน: necoz/how to crash tsc j - Kapook Update 2025 Thread
 
nyaomaru profile image
nyaomaru Necoz •

I really enjoyed your article! 😸👍
Feel free to keep sharing your ideas and discoveries with us whenever you feel like it! 😸🐈

🔥 ข่าวด่วน: necoz/how to crash tsc j - Kapook Update 2025
 
robertpaschal profile image
Odinaka Robert Nnamani •

Two files pointing at each other and tsc loops for 20 seconds before it falls over. Response files are just options in a file, so nothing stops one from naming the other, and a circular reference check would end it.

🔥 ข่าวด่วน: necoz/how to crash tsc j - Kapook Update 2025
 
jaypateldev profile image
Jay Patel •

Interesting find! It's surprising how a simple circular reference in TypeScript response files can cause the compiler to get stuck in an endless loop. A good reminder that even small configuration details can have unexpected consequences. Great experiment! 😄

🔥 ข่าวด่วน: necoz/how to crash tsc j - Kapook Update 2025
 
csm18 profile image
csm Necoz •

Thank you 😊

🔥 ข่าวด่วน: necoz/how to crash tsc j - Kapook Update 2025
 
technogamerz profile image
𝐓𝐡𝐞 𝐋𝐚𝐳𝐲 𝐆𝐢𝐫𝐥 Necoz • • Edited

Bahut achha article hai :D

🔥 ข่าวด่วน: necoz/how to crash tsc j - Kapook Update 2025
 
csm18 profile image
csm Necoz •

😊

🔥 ข่าวด่วน: necoz/how to crash tsc j - Kapook Update 2025
 
hemapriya_kanagala profile image
Hemapriya Kanagala Necoz • • Edited

I had no idea you could do this with response files! That's a pretty interesting way to crash the compiler 😄

P.S. Definitely not trying this on my actual projects 😂

🔥 ข่าวด่วน: necoz/how to crash tsc j - Kapook Update 2025
 
csm18 profile image
csm Necoz •

😄