Comment by satvikpendem

12 hours ago

A very interesting project because I always thought TypeScript or at least some subset of it should be natively compiled.

It looks like others had a similar idea too, adding a "sound mode" to TypeScript, such as this project which is converting tsgo to Rust, also with LLMs.

https://tsz.dev/

Just a clarification that tsz is not a port of tsgo or tsc. It's an entirely different architecture. Inspired by Chalk and Salsa it does all of the type computations to a solver crate that does not know about the AST. This allows me to do very fast type equity and assignability computations without carrying the weight of AST nodes while walking the type graph etc.

It's already showing results that is nearly 3x faster than tsgo. For multi-file large projects I have some ideas to implement to make it faster there too.

Once tsz is fast and stable I'll shift focus on making sound mode a reality.

  • FYI many of the tsz sound mode features are available as linter plugins for typescript. They leverage type information

> such as this project which is converting tsgo to Rust

If you'd like to follow, here's my attempt at converting tsgo to typescript (called tsts [1]). Admittedly there's AI involved, but it's a very mechanical job. Going from golang to ts is not a very difficult problem, the other way around would have been way harder. The plan is to then compile tsts to binary via tsonic.

[1]: https://github.com/tsoniclang/tsts

  • Interesting, seems to be a very roundabout way of doing it. Have you tried compiling the current TypeScript implementation which is still in TypeScript, as tsgo is for TS 7? If so, what were the results?

    • Yep. The MS compiler written in TypeScript has a lot of dynamic behavior which tsonic cannot support. Those were not easy to port either, and tsgo seemed like a much easier target.

  • Uhm... You're trying to port Typescript's Typescript-to-Go port back to Typescript? Am I missing something?