Confi.dev

TypeScript Goes Native: Unlocking 10x Performance Gains with Go

a purple background with the words go typescript and ts
a young man in a blue shirt is standing in front of a tree .
Adda Conficius

What Does It Mean to Port to a Native Language?

Traditionally, the TypeScript compiler (tsc) has been written in TypeScript itself and executed via a JavaScript runtime (Node.js). While this approach has served well for many years, it comes with inherent performance limitations when scaling to massive codebases.

Porting to a native language involves rewriting or “translating” the existing code so that it compiles directly to a native binary. This new binary can run on an operating system without relying on an intermediate runtime environment. The benefits include:

  • Faster Execution: Native binaries typically run much faster because they execute directly on the hardware without the overhead of an interpreter.
  • Improved Memory Management: By leveraging lower-level control and native garbage collection, the application can use memory more efficiently.
  • Enhanced Concurrency: Native languages often provide better mechanisms for multithreading and parallel processing, crucial for speeding up complex operations like code analysis and type checking.

This transformation isn’t about a complete rewrite from scratch. Instead, Microsoft is porting the existing codebase file-by-file to maintain almost identical behavior—ensuring that your current TypeScript projects continue to work seamlessly while enjoying significant performance improvements.


Why Go? The Strategic Choice

When evaluating options for a native implementation, Microsoft’s TypeScript team considered several languages—including Rust, C, and C++. Ultimately, Go emerged as the ideal candidate. Here’s why:

  • Optimized Native Code Execution: Go produces statically compiled binaries that run efficiently without needing a separate runtime. This results in faster execution and lower latency for compute-intensive tasks.
  • Superior Concurrency Model: Go’s built-in support for concurrency and its lightweight goroutines enable the compiler to handle parallel tasks more effectively, drastically reducing build times.
  • Robust Garbage Collection: Automatic memory management in Go reduces memory usage and avoids many of the pitfalls associated with manual memory management.
  • Ease of Integration: Go’s design and simplicity make it a great match for TypeScript’s recursive and immutable data structures. It strikes the right balance between low-level control and developer productivity.
  • Cross-Platform Support: With Go, the resulting native binaries can be easily deployed across different operating systems, further expanding the reach and utility of TypeScript.

Anders Hejlsberg, lead architect of TypeScript, summarized these benefits in his recent announcement, highlighting Go’s ability to “provide full optimized native code support on all platforms” while delivering drastic performance improvements.

The Performance Gains: Speeding Up Development

The performance enhancements promised by the native Go implementation are nothing short of remarkable. Early benchmarks show:

  • Compilation Speed: The VS Code codebase, which previously took 77.8 seconds to compile with the JavaScript-based tsc, now compiles in just 7.5 seconds—a more than 10x improvement. Similar gains have been observed in other projects like Playwright and TypeORM.
  • Editor Responsiveness: With an 8x improvement in project load times, developers can now experience near-instantaneous feedback when opening their codebases in editors such as Visual Studio Code.
  • Reduced Memory Footprint: The native implementation cuts overall memory usage significantly, which is particularly beneficial for large-scale applications where memory constraints were previously a major concern.

These enhancements not only speed up builds but also empower the next generation of development tools—ranging from advanced refactorings to AI-powered code assistants—that rely on rapid, real-time feedback.

Transitioning: TypeScript 6 vs. TypeScript 7

Recognizing the critical role that TypeScript plays in modern web development, Microsoft has devised a dual-release strategy:

  • TypeScript 6 (JS-based): The current, JavaScript-based compiler will continue to be maintained in the 6.x series. This ensures stability and backward compatibility for projects that depend on legacy configurations or specific API features.
  • TypeScript 7 (Native): Once the native Go implementation achieves full feature parity with the existing compiler, it will be released as TypeScript 7. This new version will eventually become the default for projects seeking higher performance and efficiency.

This gradual transition ensures that developers can adopt the native version when they’re ready, without being forced to make an immediate switch. The long-term goal is to keep both implementations closely aligned so that upgrading to TypeScript 7 is as smooth as possible.

Implications for Developers and the Ecosystem

The move to a native compiler has broad implications for the developer community:

  • Enhanced Developer Experience: Faster build times and responsive language services translate directly to a more fluid coding experience. Developers will notice improvements from the moment they open their editor.
  • Empowering Next-Generation Tools: With dramatically reduced latencies, new tools powered by artificial intelligence and machine learning can integrate deeper insights into codebases, offering advanced refactoring suggestions and real-time error detection.
  • Scalability for Large Projects: Large enterprises and open-source projects that have struggled with slow build times and high memory usage will now be able to scale their TypeScript codebases more efficiently.
  • Ecosystem Growth: By leveraging a native implementation, TypeScript reaffirms its position as one of the most loved and widely adopted languages in modern software development.

Looking Ahead

Microsoft’s initiative to port TypeScript to a native implementation using Go is a testament to the company’s commitment to evolving developer tools in response to real-world challenges. While the transition is still underway—with a preview of command-line type-checking expected by mid-2025 and a complete solution by the end of the year—the future looks incredibly promising.

As the native TypeScript compiler matures, developers can expect a transformative impact on productivity, scalability, and innovation in the ecosystem. This bold step not only addresses current performance challenges but also paves the way for exciting new features and integrations that will redefine what’s possible in modern development.

Final Thoughts

Porting TypeScript to a native language is more than just a technical upgrade—it’s a strategic leap toward a faster, more efficient future for web development. By choosing Go, Microsoft has unlocked the potential for dramatic performance gains and set a new standard for how programming languages can evolve to meet the demands of modern, large-scale projects.

Whether you’re a seasoned TypeScript developer or just starting your journey, these changes signal a promising new era where rapid feedback, efficient tooling, and scalable performance become the norm.

Stay tuned for more updates as Microsoft continues to refine and expand this groundbreaking initiative!

Please sign in to view comments.