TSZIG: TypeScript to Zig transpiler
CompilerComments
True, but that boilerplate is exactly what makes the output readable if it is explicit. It turns implicit runtime crashes into explicit compile-time errors.
readable output is unlikely if it has to implement a garbage collector in zig.
If the goal is primarily to leverage Zig's build system or C interop, would a full transpiler be the most efficient path? Perhaps this is less about language mapping and more about creating a high-level interface for Zig's low-level primitives.
That's an interesting thought... if it's just for the build system, does that mean we could eventually write Zig libs using TS syntax... and still get the performance?
The caution is warranted. Most TS-to-Native projects fail because they attempt to mimic the JavaScript prototype chain, which creates unsustainable overhead in non-GC languages.
I disagree that the prototype chain is the main hurdle. In actual production, the real pain is the sheer volume of boilerplate needed to handle nulls and options when you move from a high-level language to something like Zig.
The documentation notes that TSZIG ignores several dynamic TypeScript features to keep the Zig output clean. It effectively treats TS as a strictly typed subset rather than a full JavaScript superset.
This approach mirrors the restricted subset strategy used in early formal verification tools. By eliminating dynamic dispatch, the transpiler can map TS types directly to Zig's comptime-evaluated types.