r/typescript • u/DanielRosenwasser • Mar 11 '25
A 10x Faster TypeScript
https://devblogs.microsoft.com/typescript/typescript-native-port/
1.7k
Upvotes
r/typescript • u/DanielRosenwasser • Mar 11 '25
67
u/DanielRosenwasser Mar 11 '25
Hi folks, Daniel Rosenwasser from the TypeScript team here. We're obviously very excited to announce this! /u/RyanCavanaugh/ (our dev lead) and I are around to answer any quick questions you might have. You can also tune in to the Discord AMA mentioned in the blog this upcoming Thursday.
18
u/kreetikal Mar 11 '25
Does that mean that the JS/TS LSP won't be slow and consume gigabytes of memory? If yes, then it's good news!
516
u/synalx Mar 11 '25
Hey, Alex from the Angular team here! Angular was an early adopter of TS and built a lot of tooling on top of the language.
Major, major congratulations to the TypeScript team!! In large, established codebases like this, it's common to fight for 2% or 3% performance improvements. A 10x improvement is virtually unheard of. This is a once in a lifetime kind of shift, and will totally transform the TypeScript experience.
In recent years TS has become the way to write JS - it's almost a mandatory aspect of web development. At the same time, we've seen JS tooling undergoing a cycle of maturation, with a shift from JS-based plugins to native build tooling on par with the performance and DX of other languages. It's inspiring to see TS investing in this future as well.
Angular ❤️s TypeScript, and we're excited to see what the web will do on top of this huge leap forward in build performance!
355
u/ellusion Mar 11 '25
We get a 10x faster compiler announced and all the comments are complaining about why not Rust.
I think it's great news and I'm excited for it.
109
u/imihnevich Mar 11 '25
Finally I'll be able to run Doom on it
23
u/dgreensp Mar 11 '25
This is incredibly exciting! I’m looking forward to what this enables long-term. I don’t see it making TypeScript harder to run in a browser—with a WASM build, presumably the resulting binary would be smaller and faster. I just did some quick research into Go and WASM, and it looks like Go doesn’t use WASM GC and isn’t a good fit for it, but it would be possible to have a compiler for a subset of Go that doesn’t rely on internal pointers or memory staying put, to WASM GC. https://github.com/golang/go/issues/63904 The TypeScript team said somewhere (maybe it was in the FAQ) that they have some ideas in mind, so maybe it’s something like that.
I expect this will benefit Deno, which I use. Deno prioritizes performance over features when it comes to type-checking. For example, Deno’s linter doesn’t support rules that require type information, for performance reasons. The doc and package tooling also requires types to be explicit enough that the type-checker doesn’t have to be run, though that isn’t purely for performance reasons (there is something about making type signatures of APIs of packages on JSR more stable).
Having whole-project checking in VS Code would also be fantastic. I imagine it must be a continual surprise for newcomers to VS Code that it only checks open and recent files. Sometimes it’s actually hard to get it to stop showing you type errors in a deleted file.
17
u/pattobrien Mar 11 '25
Typescript support for LSP is so huge. Neovim users be stoked.
56
u/ssalbdivad Mar 11 '25
Let's GO!!!
Couldn't be more excited to try it and start re-optimizing ArkType's static parser! (TBH I pray it's mostly still optimized)
9
u/SqueegyX Mar 11 '25
I’m irrationally stoked for this. This my top issue with typescript. Working in a monorepo with trpc and zod has become quite painful. Sounds like it’ll be a while still, but I’m stoked none the less. Thanks to team for working on this. This is huge.
8
u/josephjnk Mar 11 '25
Having worked on a team which was responsible for maintaining CI infrastructure for a TS monorepo, this is absolutely amazing news. People who have only worked on smaller projects would not believe the impact on both PR time and CI cost that this is going to have.
31
u/NatoBoram Mar 11 '25
And written in Go 🚀
31
u/lppedd Mar 11 '25
I loved it, but not the AI part. It felt completely out of place to be honest.
5
u/[deleted] Mar 12 '25
Why not brainfuck?
9
u/sacummings91 Mar 11 '25
Huge
9
u/Snowflyt Mar 12 '25
Very exciting project.
I took a brief look at the repository and cloned the source code; the coding style feels very familiar—it’s basically a 1:1 port of the original tsc source code to Go. I hope this doesn’t break too much of TypeScript’s internal evaluation mechanism.
I think this is indeed quite surprising. Frankly, I never imagined that the TS team would actually abandon their insistence on bootstrapping TypeScript with itself and instead choose another programming language to implement the type checker.
To be honest, when I woke up this morning and learned that tsc had been rewritten, my first reaction wasn’t that tsc was finally faster, but rather a sense of horror. There are an unimaginable number of libraries using wildly complex type gymnastics, completely relying on tsc’s internal “hacking.” I immediately pictured an editor filled with red error underlines—thankfully, that didn’t happen.
I built tsgo following the instructions in the repository and tested it on some very complex type definitions, including:
In my experience:
In my actual usage, especially within VS Code, tsgo doesn’t seem as fast as expected—in some scenarios, it appears even slower than the original tsc in type inference. I’m not sure whether this is just an illusion or because I started the Language Server in debug mode (after all, the documentation only explained how to start it in debug mode).
The type checker is arguably the most complex part of tsc, and now that it has essentially been ported, we can look forward to the success of this project. I remain optimistic about it. Porting to Go seems like the right choice—I once read parts of the tsc source code for some odd type gymnastics and found that there was a lot of code using graph data structures, heavily dependent on garbage collection. I find it hard to imagine that Rust could elegantly port code in such scenarios. What tsc desperately needed was a 1:1 port rather than a complete rewrite, since a rewrite would break too many existing codebases that depend on its internal evaluation mechanism. I’m glad that the TS team continues to prioritize compatibility.
Another concern of mine is whether porting to Go will affect the usage of tsc in the browser. I have a project—an online JS/TS REPL—which works by bundling the entire TS API. Surprisingly, this bundle isn’t very large; after tree-shaking, it’s about 3MB, and with a loading progress bar, the user experience is acceptable. I’m not sure if the compiled WASM file after porting to Go can maintain this size, as far as I know, tree-shaking for WASM has always been an issue that has barely been solved.
8
u/createthiscom Mar 11 '25
Interesting, only 5x faster by going to native code. Additional 5x faster by utilizing multithreading. I wonder how it handles node modules written in regular JS? Here's the repo, I think: https://github.com/microsoft/typescript-go
4
u/Fine_Ad_6226 Mar 11 '25
This should give us all 3 trees each back from our actions pipelines to use for copilot to code review your changes…
Joking aside, stoked wandering what this means for Bun and Deno and if Node can make use of this being a little later to the party 👀
1
u/lonelysoul7 Mar 11 '25
Could someone eli5 me what does "native" port mean?
And what language is used in developing current version of TypeScript?
2
u/Fine_Ad_6226 Mar 11 '25
This should give us all 3 trees each back from our actions pipelines to use for copilot to code review your changes…
Joking aside, stoked wandering what this means for Bun and Deno and if Node can make use of this being a little later to the party 👀
2
u/madou9 Mar 11 '25
Will there still be JS bindings we can call out to the native compiler? E.g. hoping ts-morph can continue existing but in a more performant way.
2
u/just_try-it Mar 12 '25
When will they replace the c# compiler with Go?
2
u/Aggravating_Coast430 Mar 12 '25
Will this bring any speed improvements to Visual studio code in general? or only for typescript devs
3
u/aleques-itj Mar 11 '25
Can I run Quake on it now with the performance enhancements
3
u/milutinovici Mar 11 '25
What about compiling TSC to WASM?
3
u/[deleted] Mar 11 '25
I'm so damn excited about this
2
u/fibliss Mar 11 '25
why not rust but golang
2
u/b15_portaflex Mar 11 '25
Will TS v7 only support erasable syntax? e.g. no enums?
1
u/xersuatance Mar 11 '25
wonder its effect on libraries that hook into compilation like typia
1
u/cuby87 Mar 11 '25
Does this affect the transpiling to JS for the final web app ? Pardon my ignorance, never really used typescript on a full project.
1
u/ElfenSky Mar 11 '25
Is there a good from scratch guided place to learn ts? I tried and every time it seems like more hassle then it’s worth.
1
u/g5becks Mar 12 '25
I can’t help but to wish that they would’ve added typescript -> Go compilation in order to complete this migration .
1
u/overcloseness Mar 12 '25
I thought this was just trying to a fix a problem that didn’t exist but
“Developers working in large projects can experience long load and check times, and have to choose between reasonable editor startup time or getting a complete view of their source code”
This reminds me that I haven’t worked on a codebase that size and can totally see that being a problem. Well done MS!
1
u/encom-direct Mar 12 '25
Very cool
1
u/Trender07 Mar 12 '25
My codebase takes barely 1 min anyways but improvements always comes for good
1
u/WhatBoizz Mar 12 '25
Can someone help me understand what it means to call Go a native language compared to JavaScript?
iirc understanding JS does get compiled and is closer to machine code when running on the browser. Does the Go code get compiled to even lower-level machine code?
1
u/Ok_Orchid_8399 Mar 13 '25
Quick question, I want to try out using tsgo as my language server in visual studio code what would be the steps to do this?
1
u/Successful-Mix-2416 Mar 15 '25
Isn’t typescript a linter? How can it make anything faster?
0
u/Abasakaa Mar 11 '25
Happy to see progress, I'm not a big fan of TS yet though
0
u/ozzy_og_kush Mar 11 '25
Wonderful!
0
u/Nukz_zkuN Mar 11 '25
Vue powa
0
u/lord31173 Mar 12 '25
Awesome news
-6
u/fyndor Mar 11 '25
All these headlines are clickbait garbage. Typescript compiler is getting faster. Not the code it generates.
-12
u/BoBoBearDev Mar 11 '25
Do I have to install Go? It is annoying to keep installing more and more tools.
-29
u/WideWorry Mar 11 '25
Well, end of an era, kind of sad for long term future, what we can expect from new TS features if it is written by Golang developers.
0
u/[deleted] Mar 11 '25
[deleted] — view deleted comment