Back

Cloudflare introduces tsrs, a Rust port of the TypeScript compiler
SiTech AI Team3 min read

Cloudflare introduces tsrs, a Rust port of the TypeScript compiler

Cloudflare, VoidZero and Max Schwenk of Owner.com are building tsrs, a Rust port of the TypeScript compiler with the TypeScript team, inside the Oxc toolchain to speed up checks and cut memory use.

A faithful Rust port

Cloudflare and VoidZero are working with Max Schwenk of Owner.com on tsrs, a Rust port of the TypeScript compiler. The project is incubated as part of the Oxc JavaScript compiler toolchain and is being developed in close collaboration with the TypeScript team. The stated goal is to help developers spend less time waiting for code checks and more time building, while making TypeScript faster and more memory efficient.

The teams say this is not a fork of TypeScript. They say the TypeScript team should remain in full control of the language design and direction, and that a Rust port must follow upstream decisions closely or risk becoming incompatible. TypeScript in Rust aims to be a faithful port. An experimental release can be installed from npm with 'npm install tsrs' and run with 'npx tsrs'.

Performance and memory claims

Early benchmarks shared by the teams show tsrs up to 8x faster and using about 70% less memory than TypeScript 7.0 when using the same number of type check workers. They say the comparison was made with the TypeScript team to match the same configuration. TypeScript 7.1 beta is already up to 2.5x faster than TypeScript 7.0, and some of those optimizations were upstreamed from tsrs.

By default, tsrs ships with an adaptive configuration that depends on the machine type. That default uses more memory but is even faster. The teams also note that some public benchmarks use larger machine types or different options than TypeScript defaults, which can change performance claims.

Why Rust matters beyond speed

The teams say previous port attempts had limited success, with the TypeScript team's port from JavaScript to Go being the one that succeeded. They argue there is still demand for faster TypeScript. Rust is presented as a better fit for WebAssembly because compiling Go to WebAssembly also brings Go's garbage collector, while Rust's memory model allows straightforward memory interactions between a WebAssembly guest and host.

Cloudflare Workers have long supported WebAssembly, and the company recently announced native Rust support in Workers through an Emscripten target for wasm-bindgen. The teams say a small memory footprint makes it practical to run build and deployment systems in tight loops on Workers, and even to run sandboxed development toolchains on Cloudflare, in a browser, on embedded devices, or in IoT applications.

Maintenance and next steps

Cloudflare says it is working with Theo Browne to merge tsc-rs and tsrs into one package that supports TypeScript features including the Language Server Protocol and content mappers. The maintenance plan is modeled on Vinext: each morning an agent reviews changes, fetches diffs, and opens tracking issues; each night a compatibility matrix is regenerated by running the Next.js test suite against Vinext. When gaps appear, agents can build a reproduction, port relevant tests, and propose fixes.

The teams say they will take care not to diverge from upstream TypeScript and will try to contribute performance improvements back to the TypeScript Go codebase. They acknowledge current differences, such as the order in which diagnostics are printed, and aim to reduce them before a stable release. Cloudflare also says the Oxc team is refactoring for speed, memory use, and maintainability, and that deeper tsrs integrations could include type-aware lint rules in Oxlint.

Sources: Cloudflare · The New Stack

SiTech

SiTech — AI-powered web development

We build fast, modern websites and bring AI into real business workflows. Have a project or a question? We'd love to help.