Contents

tsrs is an experimental project to port the TypeScript compiler to Rust. Early benchmarks report up to 8× faster type checking and roughly 70% lower memory usage compared with TypeScript 7.0. It is worth trying on your own projects, but compatibility gaps and configuration differences make it too early to consider replacing your current compiler.

Key Takeaways#

  • Cloudflare, VoidZero, and Max Schwenk of Owner.com are developing tsrs as part of the Oxc JavaScript compiler toolchain, working closely with the TypeScript team.
  • Early benchmarks report up to 8× faster performance and roughly 70% lower memory usage than TypeScript 7.0 with the same number of type-checking workers.
  • Built in Rust, tsrs is a candidate for memory-constrained WebAssembly environments, such as browser-based developer tools and Cloudflare Workers.
  • The npm release is experimental, with known behavioral differences and plans to combine tsrs and tsc-rs into a single package.

What tsrs Changes#

tsrs aims to implement TypeScript in Rust while preserving its existing behavior. It does not propose a different language or a new direction for TypeScript. The TypeScript team remains responsible for language design, and tsrs must follow its decisions.

This distinction matters when evaluating it. A fast compiler is useful only if it understands your code correctly. Adoption should depend on whether tsrs handles your project's types, configuration, and diagnostics consistently with the official compiler.

The plans extend beyond command-line type checking. The team is working with Theo Browne to combine tsc-rs and tsrs into a package supporting all TypeScript features, including Language Server Protocol support and content mappers. These are stated goals, not an indication that the experimental release already covers everything.

Read the Benchmarks Carefully#

The headline figures compare tsrs with TypeScript 7.0 using the same number of type-checking workers. According to the project, the team worked with the TypeScript team to align benchmark settings and avoid giving one implementation more resources than the other.

This comparison also shows how quickly baseline performance is changing. TypeScript 7.1 beta is reportedly up to 2.5× faster than TypeScript 7.0. Some optimizations from tsrs have also been incorporated upstream. An 8× improvement over 7.0 therefore does not imply the same advantage over 7.1 beta or the compiler version your project uses.

By default, tsrs uses adaptive settings tailored to the machine. These can deliver further speed gains at the cost of higher memory usage. For a useful local comparison, record the following:

  • Exact compiler versions and commands.
  • Worker counts and configuration options.
  • Type-checking times across multiple runs.
  • Peak memory usage and diagnostic differences.

Why Rust Matters#

Faster local type checking is not the only practical reason to build another implementation. Rust can compile to WebAssembly without bundling a garbage collector, potentially reducing memory overhead in constrained environments.

This makes tsrs well suited to development environments running in browsers or on Cloudflare Workers. A smaller compiler memory footprint could make it easier to run type checking alongside other build tools in sandboxes, including environments used by coding agents.

These are potential uses, not measured results across all target environments. The published benchmarks do not establish browser startup times, WebAssembly bundle size, or memory consumption within a particular Workers application. Verify each separately if it is a deciding factor.

Try It on Your Own Project#

Install the experimental package on a temporary branch or in a disposable checkout.

snippet.txt
npm install --save-dev tsrs
npx tsrs

Start with a project you already check with TypeScript. Record the existing compiler's results, then run tsrs with the same configuration. Compare reported errors as well as runtime and memory usage. A successful exit alone does not establish that both compilers checked the same files and produced equivalent results.

Keep your existing TypeScript checks in place during evaluation. If tsrs produces different results, narrow the issue down to a small reproduction before deciding which compiler is correct. For editor use, verify the language service features you need individually rather than inferring support from command-line performance.

Compatibility Needs Verification#

The team acknowledges current differences from official TypeScript, including the order in which diagnostics appear. Even ordering differences can affect scripts or snapshots that compare compiler output directly.

Maintaining compatibility requires ongoing work. The proposed process uses agents to review upstream changes, track suspected compatibility gaps, run compatibility tests, and suggest fixes. The team also intends to contribute applicable performance improvements back to TypeScript's Go implementation.

This process is a maintenance plan, not proof of full compatibility today. Before adopting tsrs for required checks, verify your project's diagnostics and the compiler behavior your build depends on. Recheck those results whenever either compiler changes.

Next Steps#

Run tsrs on one representative project in a temporary branch, and save its type-checking times, peak memory usage, and diagnostic results compared with your current TypeScript compiler.

Source: https://blog.cloudflare.com/typescript-rust-port/

Contents