Hacker News new | ask | show | jobs
by gobdovan 64 days ago
I don't see anything wrong that would disqualify your plan. But if the alternative is regex, and you're writing already in TypeScript, you may take a look at ts-morph [0]. TS has very good compiler APIs and that gets you something much safer than text-based replacement while still staying relatively small for a constrained subset. ts-morph wraps those APIs cleanly.

Btw, JS doesn't even have an official bytecode. The spec is defined at the language semantics level, so each engine/toolchain invents its own internal representation.

[0] https://github.com/dsherret/ts-morph

1 comments

oh, hell yeah! I hadn't heard of ts-morph. Seems like it would make transpiling to C# much simpler. I'll definitely give it a try. Thanks!