Blog

A 10x Faster TypeScript: The Future of Performance and Productivity

Software

Boosting TypeScript Beyond Limits

Introduction

TypeScript has been a game-changer for JavaScript developers, offering static typing and a rich development experience. However, as projects grow, so do compilation times, memory consumption, and editor performance issues. Recognizing these challenges, the TypeScript team at Microsoft has embarked on a transformative journey: Project Corsa, a native port of the TypeScript compiler and tools.

This initiative promises a 10x performance improvement in compilation speed, reduced memory usage, and an overall smoother development experience. Let’s explore what this means for developers, how the team is achieving these results, and what the future holds for TypeScript.




The Need for Speed: Why TypeScript Needed a Native Compiler

From its inception, TypeScript has been implemented in JavaScript (or rather, in TypeScript itself). While this brought benefits in terms of accessibility and maintainability, it also imposed significant performance limitations. JavaScript’s runtime is optimized for UI and browser-based tasks rather than compute-heavy workloads like compilation and type checking.

Developers working on large-scale applications often faced:

  • Slow editor startup times, forcing them to choose between speed and complete project awareness.
  • Long compilation times, sometimes taking minutes for larger projects.
  • High memory consumption, leading to frequent out-of-memory errors.

To address these issues, the TypeScript team decided to port the compiler to Go, a language well-suited for highly performant, concurrent applications. The result? A 10x improvement in compilation speed and drastically reduced memory consumption.




Project Corsa: TypeScript Goes Native

Project Corsa is not a rewrite but a direct port of the existing TypeScript compiler. This ensures that all existing semantics and behaviors remain the same while reaping the benefits of native performance.

Why Go?

The team considered multiple languages, including C, C++, and Rust, before settling on Go. The decision was driven by Go’s:

  • Native performance optimizations across platforms.
  • Automatic memory management (without the overhead of JavaScript’s flexible object model).
  • Built-in concurrency features, allowing for parallel processing of large projects.
  • Ease of integration with existing TypeScript tooling.
MM

Matheus Miranda Teixeira

Software Engineer