TypeScript 6 Released Ahead of Go Rewrite
The new version of TypeScript, version 6, has been released, introducing incremental improvements to type inference and performance. Maintainers are encouraging development teams to upgrade now in preparation for a future full rewrite of the TypeScript backend in the Go programming language, which will introduce further changes.
- The TypeScript compiler was originally written in TypeScript itself, which allowed it to be self-hosted and portable. However, as codebases grew, this JavaScript-based compiler became a performance bottleneck, unable to take full advantage of multi-core processors for parallel type-checking. - The rewrite to Go is projected to make the compiler up to 10 times faster. In early benchmarks with large codebases like VS Code's (over 1.5 million lines of code), compilation times dropped from 77 seconds to just 7.5 seconds. This is achieved through Go's native binary compilation and support for shared-memory concurrency. - Go was chosen over other languages like Rust and C# primarily for its structural similarity to TypeScript's existing codebase, which simplifies the porting process. According to TypeScript's lead architect, Anders Hejlsberg, Rust's lack of automatic garbage collection and cyclic data structures made it unsuitable for a direct port of the existing compiler's logic. - TypeScript 6.0 introduces significant performance gains even before the Go rewrite, with incremental builds reportedly being 40-60% faster on average projects. This is accomplished through improved caching of type relationships and optimized parsing of declaration files. - This version deprecates older ECMAScript targets like ES5 and changes defaults to be stricter, such as enabling `strict` mode by default to catch more errors at compile time. - The update adds built-in types for the `Temporal` API, a modern JavaScript feature for working with dates and times that has reached Stage 3 in the TC39 process. - While the language itself evolves, Hejlsberg suggests the most significant future changes will be in tooling, adapting to an AI-native world where AI agents query language services to refactor and analyze code, shifting the developer's role more toward supervision.