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
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.txtand2.txt. - Fill them with this:
1.txt:
@2.txt
2.txt
@1.txt
- Run the spell, I mean give the file to
tsc:
tsc @1.txt
(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 (9)
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.txt2.txt:@1.txtWithout 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! π
Oh, I forgot the @.
Thanks for trying it.
I will update it in the article πΈππ»
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.
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! π
Bahut achha article hai :D
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 π
π Coooool!!!
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 πππ
Great article! πΈ