Cloudflare leads Rust port of TypeScript written by agents
Cloudflare and VoidZero collaborate on tsrs to speed up checks by eight times and cut memory use by seventy percent.
Photo: Cloudflare BlogKey points
Cloudflare is collaborating on tsrs, a Rust port of TypeScript that is up to 8x faster and uses 70% less memory.
Cloudflare is collaborating on tsrs, a Rust port of TypeScript that is up to 8x faster and uses 70% less memory. Cloudflare and VoidZero are now working with Max Schwenk of Owner.com on tsrs, a Rust port of the TypeScript compiler. They are doing this work in close collaboration with the TypeScript team and incubating tsrs as part of the Oxc JavaScript compiler toolchain.
Early benchmarks of the Rust port of TypeScript are promising. tsrs is up to 8x faster and uses ~70% less memory compared to TypeScript 7.0 when using the same number of type check workers. The next version of TypeScript already brings many performance improvements making TypeScript 7.1 beta up to 2.5x faster than TypeScript 7.0.
Early performance benchmarks show gains
Some of these optimizations were upstreamed from tsrs and the team hopes to find more. Cloudflare worked with the TypeScript team to ensure the benchmarks are comparing the same configuration rather than using larger machine types and different options compared to TypeScript defaults. By default, tsrs ships with an adaptive configuration dependent on the machine type that uses more memory but is even faster. The project aims to help developers spend less time waiting for their code to be checked and more time building.
Rust offers unique advantages including running in WebAssembly. When you compile a Go program to Wasm, you have to compile Go’s garbage collector along with it. But Rust’s memory management model enables straightforward memory interactions between a WebAssembly guest and host making it a better fit for the WebAssembly use case.
Why Rust over Go or JavaScript
Cloudflare Workers have supported Wasm for a long time. Just a few weeks ago they announced supporting native Rust in Workers with the new Emscripten target for wasm-bindgen. Running entire software build and deployment systems in tight loops on Workers means the benefits of a small memory footprint pay off quickly.
This enables new possibilities when combined with agents. You are now able to run a development toolchain end-to-end in a fully sandboxed environment on Cloudflare. But with Wasm, you can also run those environments safely client-side in your browser or on an embedded device or an IoT application. Cloudflare is working with Theo Browne to merge tsc-rs and tsrs into a single package that supports all of TypeScript’s features including Language Server Protocol and content mappers. They have seen a lot of success with how they maintain Vinext in sync with its upstream Next.js.
Agent driven maintenance process
Each morning, an agent reviews the changes, fetches diffs, and opens tracking issues for anything that could affect Vinext. Every night, the compatibility matrix is regenerated as they run the Next.js test suite against Vinext. When one of these tests or issues reveals a gap, agents can identify the change across both codebases, build a reproduction, port any relevant tests, and propose a fix.
They will apply the same process to TypeScript taking extreme care that they do not introduce diverging behaviors from upstream TypeScript. When they come across performance improvements, they will attempt to contribute them back to the TypeScript Go codebase so everyone wins. They recognize there are some differences like the order in which diagnostics are printed and aim to reduce those differences to a minimum by the time they publish a stable release.
Frequently asked questions
How much faster is tsrs compared to TypeScript 7.0?
Early benchmarks show tsrs is up to 8x faster and uses ~70% less memory compared to TypeScript 7.0 when using the same number of type check workers.
Why is Rust preferred over Go for this port?
Rust offers advantages for WebAssembly because its memory management model enables straightforward memory interactions between a WebAssembly guest and host without compiling a garbage collector along with it.
How will tsrs be maintained going forward?
Agents will review changes daily and regenerate compatibility matrices nightly. They will identify gaps, build reproductions, port tests, and propose fixes to avoid diverging behaviors from upstream TypeScript.


