Frontend

Cloudflare Ports TypeScript to Rust for Speed and WebAssembly

Cloudflare and VoidZero are building tsrs, a Rust implementation of the TypeScript compiler that achieves up to 8x faster performance and 70% lower memory usage.

3 min readSource: Cloudflare Blog

Curated by Kandala Guruprasad. Drafted with AI and checked against the source.

Cloudflare Ports TypeScript to Rust for Speed and WebAssembly

TL;DR

  • Cloudflare and VoidZero have released tsrs, an experimental Rust port of the TypeScript compiler in collaboration with the TypeScript team and as part of the Oxc toolchain.
  • Early benchmarks show tsrs is up to 8x faster and uses approximately 70% less memory compared to TypeScript 7.0 with the same type-checking worker configuration.
  • The Rust implementation enables TypeScript to run efficiently in WebAssembly, opening possibilities for development environments in browsers, Cloudflare Workers, and embedded devices.
  • tsrs is not a fork; the TypeScript team retains full control of language design, and Cloudflare plans to upstream performance improvements and maintain strict compatibility.
Performance gain
Up to 8x faster than TypeScript
Memory reduction
~70% less than TypeScript 7.0
Installation
npm install tsrs

What happened

Cloudflare and VoidZero, working with Max Schwenk of Owner.com, announced tsrs, a Rust port of the TypeScript compiler. The project is being developed in close collaboration with the TypeScript team and is being incubated as part of the Oxc JavaScript compiler toolchain. An experimental version is now available on npm for developers to try.

bash
npm install tsrs
npx tsrs

Performance and memory improvements

Early benchmarks demonstrate significant gains: tsrs is up to 8x faster and uses approximately 70% less memory compared to TypeScript 7.0 when running the same number of type-check workers. Some optimizations developed for tsrs have already been upstreamed to TypeScript itself; TypeScript 7.1 beta shows up to 2.5x performance improvement over version 7.0, partly from this collaborative work. By default, tsrs ships with an adaptive configuration that adjusts based on machine type, trading some memory for even greater speed. Cloudflare worked with the TypeScript team to ensure benchmarks use comparable configurations, addressing concerns about inconsistent performance claims in other TypeScript ports.

Why Rust and WebAssembly matter

Rust was chosen over other languages because of its superior WebAssembly support. Unlike Go, which requires its garbage collector to be compiled into WebAssembly binaries, Rust's memory model enables clean interaction between WebAssembly guest and host environments. This efficiency is critical for running TypeScript in constrained contexts. Cloudflare recently added native Rust support in Workers with the Emscripten target for wasm-bindgen, making the timing ideal for a Rust-based TypeScript compiler. A Rust implementation enables development toolchains to run efficiently in Cloudflare Workers, directly in browsers, on embedded devices, or in IoT applications—places where previous implementations would be impractical.

Maintaining compatibility and openness

Cloudflare emphasizes that tsrs is not a fork of TypeScript. The TypeScript team remains fully responsible for language design and direction. Because TypeScript's design often takes years of exploration before finalization, a faithful port must closely follow upstream decisions or risk divergence and incompatibility. Cloudflare is planning to merge tsrs with Theo Browne's tsc-rs into a single package supporting all TypeScript features, including Language Server Protocol and source maps. Maintenance will follow the model used for Vinext, Cloudflare's Next.js fork: automated agents daily review upstream changes, open tracking issues for potential impacts, and nightly regenerate compatibility matrices by running the TypeScript test suite. When gaps are found, agents identify the change across codebases, build reproductions, port tests, and propose fixes. Performance improvements will be contributed back to the TypeScript Go codebase. Minor differences like diagnostic output order will be minimized before a stable release.

Context and what's next

Many attempts to port TypeScript to other languages have failed; historically, only the TypeScript team's port from JavaScript to Go succeeded due to the complexity involved. However, frontier AI models now enable large-scale ports in days, making TypeScript ports in Rust and C++ feasible. There is clear demand for faster TypeScript. Cloudflare hosts multiple open-source Rust tools for the JavaScript ecosystem, including Vite, Rolldown, Oxlint, and Oxfmt. With over 10 million developers building on Cloudflare's platform, the company is focused on making the developer toolchain faster and more portable. Future integrations being explored include type-aware lint rules in Oxlint powered by tsrs. The goal is to maintain tsrs as a healthy open-source project without interfering with TypeScript itself, while collaborating with the TypeScript team and JavaScript community.

Source

Cloudflare Bloghttps://blog.cloudflare.com/typescript-rust-port/

AI-assisted, verified against the source. This post was drafted with AI from the primary source linked above and checked automatically against it. For anything you depend on, read the original.

  • #typescript
  • #rust
  • #performance
  • #compiler
  • #webassembly

More in Frontend