Web development: The new TypeScript compiler in Go

The TypeScript team is porting the core of the programming language to Go. This makes the language faster and improves the developer experience.

listen Print view
TypeScript and Go

(Image: erzeugt mit KI durch iX)

18 min. read
By
  • Sebastian Springer
Contents

TypeScript was once born out of necessity to compensate for JavaScript's greatest weaknesses. For years now, it has been an almost indispensable tool in web development, always slightly ahead of JavaScript in its development at feature level.

Microsoft recently announced its intention to completely overhaul the basis of TypeScript, i.e. the compiler that translates TypeScript into JavaScript and other components that are responsible for interacting with tools and development environments. Microsoft has made a surprising choice for many. Most people expected that if someone took this step, Rust would be used as the programming language, as there are already popular Rust-based tools in the JavaScript environment, such as the bundler Rspack.

Sebastian Springer
Sebastian Springer

Sebastian Springer works as a JavaScript Engineer at MaibornWolff. In addition to developing and designing applications, his focus is on imparting knowledge. As a lecturer for JavaScript, speaker at numerous conferences and author, he tries to arouse enthusiasm for professional development with JavaScript.

However, the TypeScript team with Anders Hejlsberg as lead architect opted for a reimplementation in the Go language instead. The aim of the native implementation in Go, which is compiled – rather than the just-in-time conversion of the TypeScript scripting language into bytecode –, is to improve the execution time of the TypeScript tools and to noticeably reduce memory consumption. According to current benchmarks, the new TypeScript achieves ten times faster build times for various projects.

This article is dedicated to the questions of why this improvement is so important. Where the current weaknesses of TypeScript lie and how the development of the new compiler, which is codenamed Corsa and is being run under the version TypeScript 7, is proceeding.

Videos by heise

In 2012, Microsoft released the first version of TypeScript after two years of development. Since 2014, the programming language has been publicly available for further development on GitHub and is subject to the Apache 2.0 license as an open source project. TypeScript has now reached version 5.8.

At its core, TypeScript is a programming language that adds type safety to JavaScript at compile time – with the aim of making it easier to develop larger applications and creating a basis for better development tools.

There are several reasons for using TypeScript instead of JavaScript in both front-end and back-end projects on the web:

  • Static typing: JavaScript has only a weak type system, which encourages runtime errors. With its largely optional static typing, TypeScript offers great flexibility on the one hand and helps developers to detect potential errors at an early stage on the other.
  • Improved code quality: TypeScript allows a strict definition of interfaces, particularly at the interfaces of modules in an application, but also in libraries, which significantly improves the maintainability and readability of the code. This is particularly beneficial for larger projects and reusable libraries.
  • Tool support: Numerous tools in the JavaScript ecosystem rely on TypeScript to provide better support for developers. For example, development environments such as Visual Studio Code can help significantly better in the development of a Node.js application if the type definitions of Node.js are installed. Especially regarding code autocompletion and the display of function signatures.
  • Polyfills: TypeScript supports modern features from the ECMAScript standard very early and before most environments such as browsers integrate the features across the board. TypeScript can generate different ECMAScript versions as output and therefore also supports older environments. This possibility goes back to version ECMAScript 3 (this version of the JavaScript standard was published in 1999).
  • Structured development: In addition to standard JavaScript and type safety, TypeScript introduces further constructs such as interfaces, enums and generics, which allow data structures and interfaces to be better modeled. Some object-oriented design patterns cannot be implemented in native JavaScript or can only be implemented with additional effort. The presence of interfaces makes work much easier here.
  • Strict environment: TypeScript uses configuration options such as strictNullChecks to avoid common errors from the outset.
  • Framework and library integration: Many frameworks and libraries in the JavaScript ecosystem are either directly implemented in TypeScript or at least come with type definitions so that they can integrate seamlessly into a TypeScript environment and take full advantage of it.

What is remarkable: TypeScript is (still) completely programmed in TypeScript. The core of the programming language will continue to be in TypeScript in version 6. At the same time, the team is working on version 7, which will then be the Go version and replace the TypeScript implementation as soon as the two projects have reached feature parity. The development team's current schedule envisages a fully-fledged version of the command line compiler that can perform type checking and translation of source code by mid-2025.

Currently, the TypeScript Go compiler already works almost completely for pure TypeScript code. What is still missing is support for JavaScript, JSDoc and JSX. A feature-complete version that can build projects is expected at the end of 2025. The Language Service, one of the most important development features, is also expected to be available.

But why is such a drastic step as a rewrite in another programming language necessary at all? TypeScript shows its advantages above all in larger applications. However, as the code base grows, TypeScript's resource requirements for type checking and building also increase. On the one hand, this means that opening a project in the development environment takes a long time, as the language service initially processes the code. The build of a larger application can also be very time-consuming. In addition to the pure runtime, there is another, even greater problem due to the high memory requirements. This can lead to memory problems and, in the worst case, to crashes due to out-of-memory errors.

JavaScript conference by Heise: enterJS 2025
Enterprise JavaScript Conference enterJS 2025, May 7 and 8 in Mannheim, Germany

(Image: WD Ashari/Shutterstock.com)

enterJS 2025 will take place on May 7 and 8 in Mannheim. The conference offers a comprehensive look at the JavaScript-supported enterprise world. The focus is not only on the programming languages JavaScript and TypeScript themselves, but also on frameworks and tools, accessibility, practical reports, UI/UX and security.

Highlights from the program:

Tickets are available in the online store.

Don't miss any news – follow us on Facebook, LinkedIn or Mastodon.

This article was originally published in German. It was translated with technical assistance and editorially reviewed before publication.