Rust Rewrite Makes TypeScript Up to 8x Faster
TL;DR: Cloudflare has backed an experimental Rust-based version of the TypeScript compiler called tsrs. It promises massive performance gains, potentially checking code up to eight times faster while using significantly less memory than the standard compiler.
Key facts
- Category
- Infrastructure
- Impact
- High
- Published
- Source
- InfoQ
Full summary
Cloudflare is backing tsrs, an experimental Rust port of the TypeScript compiler that promises up to 8x faster type checking.
Cloudflare, in collaboration with VoidZero and developer Max Schwenk, has announced an experimental new tool named tsrs. According to a report from InfoQ, tsrs is a port of the official TypeScript compiler, rewritten in the Rust programming language. The project, which had involvement from the TypeScript team, makes bold performance claims, suggesting it can perform type checking up to eight times faster than the standard compiler while using 70% less memory. One benchmark showed a more modest but still significant 2.7x speedup. However, the tool is in its early stages and currently lacks critical features for daily development, such as a watch mode for automatically recompiling on changes and a language server for IDE integration.
The primary innovation behind tsrs is the shift from TypeScript to Rust. The official TypeScript compiler, known as `tsc`, is itself written in TypeScript. This means it runs on a JavaScript engine like Node.js, which introduces performance overhead. By porting the compiler to Rust, a systems programming language known for its high performance and memory efficiency, developers can bypass the JavaScript runtime entirely and execute the compiler as a native binary. This approach is the main driver behind the dramatic speed improvements. The project also utilized AI to assist in the initial translation of the TypeScript codebase to Rust, showcasing a novel technique for modernizing and optimizing large, complex software projects.
This project is part of a broader industry trend of rebuilding core web development infrastructure in high-performance languages. For years, developers have relied on JavaScript-based tools for tasks like code transpilation, bundling, and minification. However, as projects grew larger, the performance of these tools became a significant bottleneck. This led to the rise of alternatives written in languages like Go and Rust, such as esbuild and SWC, which offered order-of-magnitude speed improvements. The tsrs project applies this same philosophy to TypeScript's type-checking process, which is one of the last remaining performance pain points in many modern development toolchains. Cloudflare's backing is also notable, as the company has a strong track record of investing in performance-focused developer tools and infrastructure.
For developers and technology leaders, tsrs is a project to watch closely but not one to adopt for production use just yet. The absence of a language server and watch mode makes it impractical for most development workflows. The project's current state is more of a proof-of-concept that demonstrates the potential performance gains of a Rust-based approach. The next critical steps will be for the project to build out these missing features and work toward full compatibility with the official compiler. The involvement of the TypeScript team is a promising sign that it may eventually become a viable, high-performance alternative for developers struggling with slow build times in large-scale applications.
Why it matters
For engineering teams, faster build and check times directly translate to increased developer productivity and a tighter feedback loop. For large TypeScript codebases, this could remove a significant bottleneck in the development and CI/CD pipeline, making teams more agile.
Business impact
Faster development cycles mean products ship quicker, reducing time-to-market. For companies with large engineering teams, the accumulated time savings from faster builds can represent a substantial reduction in operational costs and a significant competitive advantage.
Tags
Related on Notifire
Related stories
Primary source: InfoQ
