Not a member? Read it here.

About a year and a half ago, Primeagen, a well-known figure in the developer community, made a tweet that would spark one of the most ambitious and mind-bending coding challenges in recent memory. He jokingly tweeted that "until Doom can be created with TypeScript types, TypeScript isn't a real language."

At the time, this was a playful jab at the ever-growing complexity of TypeScript, but little did he know that this offhand comment would inspire an insane coding journey, eventually leading to the impossible: running Doom purely in TypeScript types.

The Tweet That Sparked It All

Primeagen's tweet wasn't meant to be taken seriously. It was a joke, poking fun at the often over-complicated nature of TypeScript and challenging the community to do something absurd. However, one programmer — Michigan Types — wasn't about to let the challenge go unanswered. He set out on a journey to turn the joke into a reality, building a full WebAssembly virtual machine in TypeScript types to run Doom.

The TypeScript Doom Project Begins

At first glance, the task seemed impossible. The goal? To create a fully functioning version of Doom using nothing but TypeScript types — no external execution languages, no shortcuts. What followed was a monumental undertaking.

Michigan Types started by crafting a TypeScript-based virtual machine. It was no small feat: to run the first frame of Doom required three and a half trillion lines of TypeScript types, and the TypeScript compiler needed to process it for 12 days straight. The total size of the text reached 177 terabytes, a size unimaginable for most systems to handle. And that was just the beginning.

The Technological Feats Behind the Project

Running Doom on TypeScript wasn't just about coding a game — Michigan Types had to essentially create an entire TypeScript-based computer from scratch, including:

  • A TypeScript types-based garbage collector
  • A full memory system, including L1 cache and RAM simulated entirely in TypeScript
  • Machine-level logic to execute 18 million instructions, with WebAssembly being processed purely through TypeScript.
  • An execution stack and memory protection system to prevent infinite loops and system crashes

Each component had to be painstakingly crafted from the ground up, and nothing could rely on any existing game engines or external libraries.

The Extreme Limits of TypeScript

To pull this off, Michigan Types had to push TypeScript to its absolute limits. Normally, TypeScript isn't built to handle this level of complexity, but that didn't stop the team from removing key compiler restrictions to make it work:

  • Stack depth limits were disabled
  • Unions and tuples complexity was expanded to absurd levels
  • Type inference needed to be adjusted in ways that TypeScript wasn't originally designed to handle

Despite these tweaks, the project was still an almost impossible task, with the TypeScript compiler frequently crashing under the sheer size and complexity of the code.

A Community Effort

As news of the project spread, it gained attention from the TypeScript and coding communities. Developers were fascinated by the audacity of the challenge, and many joined in to help debug or offer suggestions, making it a true community effort. Through collaboration, the project slowly but surely began to take shape.

The Incredible Achievement

After much blood, sweat, and tears, the impossible was finally achieved. Doom was running purely on TypeScript types, a feat no one could have imagined possible when Primeagen first made that joking tweet. While the project is still in its early stages and not fully optimized, it stands as a testament to the creativity and tenacity of developers in the face of seemingly absurd challenges.

So, next time someone questions the power of TypeScript, remember that yes, you can run Doom on it. It just might take a few trillion lines of code and a whole lot of determination.

None

Discover hands-on programming tutorials and resources! Visit my website: Fullstack Dev