
Migrating TypeScript to Rust: Up to 8x faster, 70% less memory usage, and even runs in browsers.
Cloudflare, in collaboration with VoidZero and Max Schwenk, has launched tsrs, a TypeScript compiler with a Rust port, within the Oxc toolchain. It boasts significantly improved performance compared to TypeScript 7.0, achieving up to 8 times faster execution and using 70% less memory. Unlike forks, tsrs leverages Rust+Wasm to enable running a complete development environment directly in the browser.
Related tags
TypeScript ported to Rust: Up to 8x faster, 70% less memory, and runs in the browser
The TypeScript compiler has a Rust port – Max Schwenk from Cloudflare, VoidZero, and Owner.com are collaborating on tsrs, which is being integrated into the Oxc JavaScript compiler toolchain. Early benchmarks show impressive results: with the same configuration, it’s up to 8 times faster than TypeScript 7.0 and uses about 70% less memory.
Not a fork, but a “faithful port”
Let’s clarify the boundaries of this project. tsrs is not a fork – Cloudflare has explicitly stated: “We believe that the TypeScript team should maintain complete control over the language design and direction, and we don’t want to change that.”
The reason is that the Rust port must strictly follow the original implementation’s semantics. If it decides on its own how the language should behave, compatibility will eventually break down. The TypeScript team may take years to explore prototypes before finalizing a solution for certain features; if the port lags behind, it will become unusable. Any changes at the language level can only be proposed through the official process.
Benchmark numbers worth noting
- Early benchmarks of tsrs: up to 8 times faster than TypeScript 7.0, and about 70% less memory (under the same number of type checking worker);
- Cloudflare emphasizes that the benchmarks are verified with the TypeScript team – there have been some “very fast” ported versions promoted on the market, which often use larger machine types and different options;
- Also, don’t forget: TypeScript 7.1 beta is already 2.5 times faster than 7.0, and a portion of this optimization comes from tsrs upstream feedback;
- tsrs defaults to an adaptive configuration based on the machine type, which uses more memory and is faster. You can adjust it back to a fixed configuration if you’re concerned about memory usage.
“Go version is already 10x faster, why Rust?”
Cloudflare answers this question itself: the key is Wasm.
The TypeScript team has already rewritten the compiler (TypeScript 7) in Go, achieving approximately a 10x speedup. However, when compiling Go programs to WebAssembly, you have to bring along Go’s garbage collector; Rust’s memory management model makes interaction between the Wasm guest and host very direct, without any GC overhead, and results in smaller outputs.
Cloudflare Workers has already supported Wasm, and just a few weeks ago announced native Rust support (wasm-bindgen for the Emscripten target). This makes something that was previously impossible possible: running a complete development environment in the browser, embedded devices, and IoT applications – the entire type checking chain does not rely on the development machine or pre-installed Node environment; the toolchain is distributed with the application. Combined with an AI Agent, it can also run a complete development toolchain end-to-end within Cloudflare’s sandbox.
Why now?
There have been many attempts to port TypeScript to other languages over the years, but only one has succeeded: the official Go port. Cloudflare points out that cutting-edge AI models can now “almost independently complete large ports in a matter of days” – recent slopforks (low-quality forks), faithful ports, and thorough refactoring versions are emerging, which indicates that there is real demand for “faster TypeScript”.
How to use and maintain
- Experimental version available on npm: after
npm install tsrsyou can run it withnpx tsrs; the experimental version does not guarantee stable interfaces; when installing, it’s recommended to fix the version number; - There are still some gaps in functionality, such as different output order of diagnostic information compared to the upstream, and the official will minimize the differences before releasing a stable version;
- Work on merging with Theo Browne’s tsc-rs is also underway, which will merge into one package and cover the Language Service Protocol (LSP) and content mappers;
- The maintenance method follows Cloudflare’s approach for Vinext: Agent reviews upstream changes daily, runs test suites every night, and tries to feed performance optimizations back into the TypeScript Go codebase.
References / Sources
- Original article: TypeScript ported to Rust: 8x faster, 70% less memory, and runs in the browser - OSCHINA
- Cloudflare official blog: Introducing tsrs: A port of TypeScript to Rust
More News
Want to see more quality content?
Browse all news