Microsoft has heavily invested in both the Chakra JavaScript engine and TypeScript. The core part of the engine is open source and cross platform. ChakraCore exposes a C API for embedding and using the engine from your own apps. Elliot Linder has started wrapping that low level API into something easier to consume in Rust.
TypeScript exposes a compiler API. I first tried it out three years ago, but I was only only able to read the TypeScript, not generate TypeScript. I've been a squeaky wheel since then, asking politely and persistently for the ability to generate TypeScript. As of TypeScript 2.3.0 release in April it is possible. Their example titled Creating and Printing a TypeScript AST shows how to do it from TypeScript itself:
Loading gist ...
Here is how I've ported it to Rust:
Loading gist ...
The two main things that could make this port much better would be if:- a trait was upcastable to a supertrait
Objects should be upcastable to supertraits #5665 - a ContextGuard did not have to be passed to every function call
access violation with call_with_this #21