Case Studies

Porting TypeScript to Rust with an LLM: The Real Story Isn't the Speedup

pingdotgg has open-sourced ts-rust, an attempt to use LLMs to fully automate a cross-language port of the TypeScript compiler, type checker, and LSP. It hit 56 points and 98 comments on HN, and the workflow matters more than the code.

Font size

HN's front page has been carrying an unusual repo for the past couple of days: pingdotgg/ts-rust. 56 points, 98 comments, more traction than plenty of serious open-source projects.

The premise is blunt: use an LLM as the lead engineer to port the TypeScript compiler, type checker, and LSP from TypeScript/JavaScript to Rust.

On the surface it sounds like another "AI rewrites everything" gimmick. After reading the README and working through the HN thread, I think there's more worth unpacking than the headline suggests.

What the project actually does

ts-rust's GitHub description is restrained: "LLM-driven TypeScript compiler port to Rust." Two words stand out:

  • LLM-driven, not "AI-assisted." The model is the main contributor; humans supervise.
  • compiler. Not a library, not a tool. The compiler itself, including the checker and LSP.

The current TypeScript toolchain is written in TS and maintained by Microsoft. The pain points are familiar: slow cold starts, heavy memory footprint, dependency installs that take forever. The community has already proven the speedup story with Rust rewrites: swc, oxc, biome all showed that reimplementing JS/TS tooling in Rust buys roughly an order of magnitude in performance.

So how is ts-rust different from swc or oxc?

  • swc: hand-written Rust, has to chase new TS features as they ship.
  • oxc: hand-written Rust, with some lessons borrowed from rustc.
  • ts-rust: the LLM writes the Rust. Humans step in only at critical checkpoints.

This is an AI-automation experiment at the toolchain level. The code isn't written by people. It's emitted by the model.

I skimmed the commit history. The repo currently sits around a few thousand lines of Rust, and the README openly states "auto-generated code with human review." Full automation is limited, but the pipeline runs end-to-end.

Why this is harder than it looks

Getting an LLM to translate a TS parser into Rust is not hard. ASTs are structured, token streams follow a published spec. The hard part is the soul of TypeScript: the type system.

A few pain points only people who've touched a TS compiler know:

  • Recursion in conditional types: T extends infer U ? U : never nested three levels deep, and the model happily writes an implementation that never terminates.
  • Cross-file type inference: A file exports a type that depends on a global type from file B. The LLM, working from local context, produces code that "looks right" but quietly breaks soundness.
  • Incremental checking: tsc's killer feature is recomputing only the slice of the dependency graph affected by a change. That data structure is the most subtle part of the TS compiler, an order of magnitude harder than the parser.
  • LSP position mapping: error positions have to be translated from Rust's internal representation back to source line and column. Endless fiddly details.

HN commenters pointed out that the LLM can get a single pass's tests green, but running the full type checker end-to-end "is still fantasy right now." That's not a model-strength problem; correctness-critical systems just don't lend themselves to pure generation.

My own intuition: getting an LLM to write an algorithm that looks right is a difficulty-3 task. Getting it to write an algorithm that's right for all inputs is difficulty-8. A compiler falls squarely in the second category.

What the HN thread is arguing about

98 comments split into a few camps:

The optimists: "If this works, single-file distribution plus 50ms cold starts would put TS on par with Go."

The skeptics: "Look at the commit history. The AI writes the code, humans frantically fix bugs behind it. Is that AI-driven or AI-assisted?"

The pragmatists: "Stop messing with a port and invest in oxc. It already covers 80% of use cases, and hand-written Rust is higher quality."

The meta crowd: "Whether or not it ships, the workflow itself is the product. You can apply it to jQuery, to Babel, to ancient C++ libraries."

That last one is the most interesting.

My take: the code isn't the point

I give ts-rust a 50% chance of ever correctly handling every TS corner case. The type system's complexity is what it is. The edge cases of infer alone could fill a small book.

But the actual deliverable here isn't the Rust compiler. It's the migration workflow.

Picture this:

  • Your company has a C++ library from 1998 that nobody dares touch.
  • Someone now stands up a pipeline: LLM generates a Rust first draft, test cases run for parity, humans review the critical paths.
  • Three months later, the library is migrated and the old C++ can be retired.

That's where AI-rewrite of legacy code starts paying real-world dividends.

People have done pieces of this before:

  • c2rust (hand-driven C-to-Rust migration)
  • Babel's SWC replacement (hand-driven JS parser migration)

But ts-rust is trying to swap out the most expensive component, the human, for an LLM-plus-review combination. If you can push the human review share down to 20%, a single migration might cost a tenth of what it used to.

One HN commenter already drew the analogy: "swc was the Go-era answer. AI-driven migration is the Rust-era answer."

I agree with the first half, not the second. AI-driven migration isn't the answer. It's a tool. The Go-era answer is still "humans write it, machines compile it."

Editor's note

What's symbolically significant is that this is the first time "LLM-led, compiler-grade cross-language migration" has been put on the table in public. Whether it succeeds or not, it defines a new role: the AI migration engineer.

My contrarian take: over the next 12–18 months, the most valuable work won't be "AI writing new code." It'll be "AI rewriting old code." New code already has Copilot and Cursor. Old code is untouched. If ts-rust's approach holds up, "AI rewrites COBOL," "AI rewrites jQuery," "AI rewrites Rails 2" could become its own open-source movement.

What makes this different from prior attempts? Every past code-migration project, c2rust, tsc-to-Rust experiments, Python 2 to 3, was human-led with AI as a sidekick. This time, AI leads and humans play defense. The power dynamic is inverted. Whether that inversion is stable, I don't know. But it proves one thing: correctness-critical systems have entered AI's range.

Caveat: ts-rust hasn't yet passed the full TS test suite. I'm not betting it will fully replace tsc. But the workflow itself deserves a serious look from anyone doing migrations.

Source: https://github.com/pingdotgg/ts-rust