AI NewsDev toolsAnnouncement

Cloudflare, VoidZero and Owner.com port TypeScript to Rust as tsrs

Cloudflare, VoidZero and Owner.com's Max Schwenk are now working together on tsrs, a Rust port of the TypeScript compiler kept inside the Oxc toolchain. Cloudflare says early benchmarks measure it up to 8x faster than TypeScript 7.0 and using about 70 percent less memory with the same number of type-check workers.

AI News

Editorial3 min read

LinkedInX

Why it mattersA faster, smaller TypeScript compiler that runs well in WebAssembly means a team can type-check a project inside the browser or an edge sandbox rather than on a developer's laptop.

Type checks are the step a TypeScript developer waits on all day. Cloudflare, VoidZero and Max Schwenk of Owner.com published a joint post saying they are now working on tsrs, a Rust port of the TypeScript compiler kept inside the Oxc JavaScript toolchain. Cloudflare says early measurements put it at up to 8x faster than TypeScript 7.0 while using about 70 percent less memory with the same number of type-check workers.

The post, by Boshen Chen, Dimitri Mitropoulos and Christoph Nakazawa, says the work is done in close collaboration with the TypeScript team at Microsoft. An experimental release ships on npm as tsrs.

A strict follower, with the benchmark configuration agreed with Microsoft

The authors position tsrs as a strict follower of the upstream compiler. The TypeScript team should remain in sole control of the language's design, they say, because a Rust port that drifts from TypeScript decisions "will eventually fall apart and become incompatible". Cloudflare says it worked with the TypeScript team to make the published benchmark compare the same configuration, in response to recent third-party benchmarks of competing ports that used larger machines or non-default options. By default tsrs ships with an adaptive configuration that uses more memory than the matched run but is faster still.

TypeScript 7.1 beta is already closing part of the gap

The same post reports TypeScript 7.1 beta is up to 2.5x faster than 7.0, and credits some of those gains to optimisations upstreamed from tsrs. The authors say they will try to contribute further performance work back to the TypeScript Go codebase so, in their words, "everyone wins". Known differences from upstream, including the order in which diagnostics are printed, are called out, and the project says it aims to reduce those to a minimum before a stable release.

The reason to pay the cost of a second port is WebAssembly

The TypeScript team's own Go port already made the compiler many times faster. The post says the case for a Rust rewrite rests on WebAssembly. A Go program compiled to WebAssembly has to carry Go's garbage collector along with it, while Rust's memory model lets a guest and host share memory directly. Cloudflare announced native Rust support in Workers through a new Emscripten target for wasm-bindgen, and the post argues a small-footprint Wasm toolchain lets a complete build and deploy system run in places it never fit before, including a browser tab, an embedded device or an IoT application.

Next, a merge with Theo Browne's tsc-rs

Cloudflare is working with Theo Browne to merge tsc-rs and tsrs into one package that covers all TypeScript features, including Language Server Protocol and content mappers. The company also plans to try tsrs inside its existing Rust tools for the JavaScript ecosystem, naming Vite, Rolldown, Oxlint and Oxfmt, with type-aware lint rules in Oxlint called out as the first integration. The port will stay in step with upstream using the keeping-current loop Cloudflare already uses for Vinext: an agent reviews upstream changes each morning and opens tracking issues, and the compatibility matrix is regenerated nightly.

The practical consequence for a team is that type checking stops being the step that sets the pace of a build. When a sub-second type check runs in a sandbox you do not own, agent-driven workflows that review a diff on each push become cheap enough to leave on by default.

Source

Introducing tsrs: a Port of TypeScript to Rust, on the Cloudflare Blog, by Boshen Chen, Dimitri Mitropoulos and Christoph Nakazawa. The source lives in oxc-project/tsrs.

This item was written by an AI system from the linked source. Reveneau is responsible for what it publishes.

Share
LinkedInX
Start a project