What's the fuss about Typescript-Go

Aqsa AqeelAqsa Aqeel
3 min read

If you’re a front-end developer, then it is impossible that you are oblivious to the news of TypeScript rewriting its compiler in Go. But if you’re a front-end developer like me, then you might also be wondering what exactly it is. What is TypeScript-Go? Is it a new version of TypeScript where you can use Go? Wait, but that isn’t possible, I remember they said they’re rewriting the compiler. So does it mean TypeScript can now produce Go code?

Let me clear up these doubts in this article. To begin with, we have to understand what TypeScript is and how it is made in the first place.

what is typescript? why is typescript?

If we go to the official TypeScript documentation, it says in bold font that "TypeScript is JavaScript with syntax for types."

But we all knew this already. TypeScript is a superset of JavaScript with a lot of static types, interfaces, and a type checker. But at the end of the day, TypeScript is not a new language. TypeScript code ultimately gets converted to JavaScript, and that JavaScript code is what gets executed.

That’s why it comes with its own compiler. This typescript compiler does 2 things:

  • does type checks

  • transpiles typescript code to javascript code

And this compiler, until now, has been written in 100% TypeScript (very inception-y, I know, but read about compiler bootstrapping if you want to know more). What this means is that when the computer processes a piece of TypeScript code, it uses the TypeScript compiler (written in TypeScript) to convert it into JavaScript.

But unfortunately, the TypeScript compiler couldn’t scale for larger codebases. It would take too long to load and had longer check times. They needed something that could compile more quickly, so they decided to use Go for it.

typescript compiler GO brrrr

To address the speed and memory issues, the TypeScript team decided to port the compiler code from TypeScript to Go. They claim that this will "drastically improve editor startup, reduce most build times by 10x, and substantially reduce memory usage." In simple terms, your TypeScript code will compile 10x faster than before.

The next question that comes to mind is: why did they choose Go for this? Why not Rust or C? While that could be an entire article on its own, I want to focus on why they preferred Go for this.

There were two options for porting:

  1. Rewrite the entire codebase in a new language.

  2. Port the existing TypeScript code to a new language.

They opted for the second option because it was quicker to implement. Go seemed to be the most compatible and easiest language to convert to. Below is a side-by-side comparison of the same piece of code written in Go and TypeScript, showing how similar their structures are.

i have a smaller codebase, i dont want to use this

Well, that’s alright! The latest version of TypeScript is 5.8, which still uses the TypeScript compiler. The TypeScript-Go compiler can only be used by building and running Go from their open-source repository.

This compiler is planned to be completed by mid-2025, and while it's optimistically compatible with most existing codebases, there are a few places where it isn’t. That’s why they will continue maintaining the TypeScript version of the compiler in version 6 and the TypeScript-Go compiler in version 7.

You can read more about it in…

https://devblogs.microsoft.com/typescript/typescript-native-port/
and also watch the annoucement news on Youtube by the lead architect
https://www.youtube.com/watch?v=pNlq-EVld70

1
Subscribe to my newsletter

Read articles from Aqsa Aqeel directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Aqsa Aqeel
Aqsa Aqeel

A front-end developer practicing her super power that is ReactJS.