tsrs Brings a Rust Type Checker to the TypeScript 7 Era


TypeScript has already made one enormous speed jump. Version 7 replaced the JavaScript-based compiler with a native implementation in Go. Microsoft reports typical full-build gains of eight to twelve times over TypeScript 6. That changes the starting point for any new compiler: beating the old JavaScript toolchain is no longer the interesting comparison. A new implementation must improve on an already fast native compiler and preserve the language behavior people depend on.

That is the problem behind tsrs, the experimental Rust port announced by Cloudflare, VoidZero, and Max Schwenk. It is being incubated in the Oxc toolchain. The team wants faster checking and a smaller memory footprint, with a path to WebAssembly deployments. They say TypeScript’s own team should continue deciding how the language works. The Rust implementation is intended to follow those decisions closely.

The target is the Go compiler’s behavior

Type checking is more than assigning a type to each expression. The compiler parses source files, resolves modules and symbols, builds a program graph, checks relationships among types, emits diagnostics, and sometimes writes JavaScript and declarations. Editors also call into a language service for completions, references, and quick information. Small changes in ordering or resolution can change what a developer sees, even when most projects compile successfully.

Microsoft’s TypeScript 7 port was deliberately faithful to the prior compiler’s structure and logic. That fidelity matters to tsrs too. A checker that runs quickly but reports different errors, accepts code the official compiler rejects, or emits different output creates a migration cost for every project that tries it. The tsrs repository states a goal of full conformance with TypeScript 7.1 and documents current gaps, including unsupported --init and --showConfig commands and differences in diagnostic ordering. Its conformance target is a goal, not a claim that every program already behaves identically.

TypeScript source and configuration flow through parsing, resolution, checking, and diagnostics or emitted output. tsrs must match the official compiler along the whole path.
Compiler compatibility includes the result and the route to it: configuration, resolution, checking, and output.

There is a practical test for that promise. Run the official Go compiler and tsrs against the same pinned TypeScript version, project, options, and worker count. Compare exit codes, diagnostic codes and locations, emitted files, and language-service answers. When outputs differ, reduce the case and decide whether the Rust port is wrong, the reference is nondeterministic, or the difference is already documented. The tsrs README describes a special --checkerAssignment go --noLazyMembers configuration for its closest comparison with Go. Parallel parsing and resolution can still make some reference outputs vary between runs.

Read the speed numbers with their denominator

Cloudflare’s initial benchmark says tsrs is up to eight times faster and uses about 70% less memory than TypeScript 7.0 when the same number of type-check workers is used. Those are early, configuration-specific measurements, not a universal forecast for every repository. The team’s separate adaptive default can use more memory to gain additional speed. That is a different tradeoff from the equal-worker comparison.

The release timing also matters. Cloudflare says TypeScript 7.1 beta can be up to 2.5 times faster than 7.0, and that some improvements from tsrs have already been contributed upstream. If a graph compares Rust against 7.0, it should not be read as a promise of the same multiplier against 7.1. The best baseline for a project’s decision is the version it actually runs, with the same machine, warm-up rules, project configuration, and output requirements.

The benchmarks expose a useful engineering tension: more check workers may lower wall-clock time while increasing CPU work and peak memory. A laptop editor, a memory-limited CI runner, and a multi-core build server may prefer different settings. Report both elapsed time and peak resident memory; test a clean run and the repeated run that resembles daily work. A fast checker that changes diagnostics or skips emit is not an equivalent workload.

Why make another native port?

The Go compiler already solves much of the ordinary command-line performance problem. Rust’s particular appeal here is portability to WebAssembly and finer control over the memory profile of the compiled module. Cloudflare describes a future in which the checker can run in a browser, an isolated Worker, or a compact development environment. Rust can target Wasm without bringing along a language garbage collector. That does not make every Rust-to-Wasm build automatically small or fast; dependencies, host calls, and memory transfer still matter. It does give the project a different deployment surface to optimize.

The tsrs project lists an @tsrs/wasm package targeting WASI Preview 1. A browser playground and Node or browser integration are part of its current direction. For a hosted development environment, the useful question is whether a complete edit-check-diagnose loop fits its memory and startup budget. For a browser, it is whether the checker can stay responsive while project files and package metadata move between the host and Wasm guest.

The same Rust type checker can run as a native command, a WASI module in a sandbox, or a browser-hosted module, each with different file access and memory constraints.
Portability creates several places to run the checker, each with a distinct host boundary.

There is also an integration argument. Oxc already contains Rust-based tools for JavaScript and TypeScript, including parsing and linting. A type checker in that ecosystem could support type-aware lint rules without repeatedly crossing process or runtime boundaries. Cloudflare mentions deeper Oxlint integration as an area to explore. It is a possibility rather than a finished product feature.

A port has an ongoing maintenance bill

The hardest part may come after the first fast release. TypeScript changes continuously: a new inference rule, parser edge case, diagnostic, or editor behavior can create divergence. Cloudflare says it will track upstream changes with automated review and a compatibility matrix, port relevant tests, and contribute useful performance work back to the official Go codebase. The plan echoes the process it uses to keep Vinext aligned with Next.js.

That process needs human decisions. A failing conformance test may reveal a bug in tsrs, an intentional upstream change, or an unstable behavior in the reference implementation. Shipping a second compiler does not grant its maintainers authority to define a competing TypeScript dialect. The project’s stated rule is to follow the official compiler and make differences visible. The announced effort to merge tsc-rs and tsrs into one package, including language-server and content-mapper support, adds another integration task to that maintenance work.

AI-assisted porting changes the economics of getting a large codebase translated, and Cloudflare explicitly points to that shift. It does not remove the need for conformance evidence. A model can produce code quickly; project tests, real repositories, controlled benchmarks, and upstream review determine whether the result is safe to use. That is why the most credible claim in this story is not that Rust alone makes TypeScript fast. It is that an independent implementation can become useful if its speed and footprint improve while its behavior stays tied to TypeScript’s source of truth.

Trying it on a real project

The experimental package can be installed with npm install -D tsrs and run with npx tsrs --noEmit. Keep the official compiler in CI while evaluating it. Start with one repository and record the compiler version, exact options, elapsed time, peak memory, exit status, and diagnostics from both tools. Try the editor path separately if language-service behavior matters to your team. A mismatch is valuable feedback even when the Rust checker is faster.

For now, tsrs is a promising experimental implementation, not a reason to assume an effortless replacement. Its value will be measured in the projects where faithful results, lower memory use, and portable execution come together.

Sources

100%