Is it possible to turn the AST back into CoffeeScript instead of into JavaScript? A project I am working basically requires turning all the CoffeeScript into the AST, analysing the AST, then turning portions of the AST back into CoffeeScript. I understand the transformation back would be 'lossy' with regards to the original code, but this is okay.
I would really like to avoid having to compile those portions to JavaScript and then back to CoffeeScript.
One crucial difference between the two languages is that TypeScript is the superset of JavaScript while CoffeeScript is a language which is an enhanced version of JavaScript. Not just these two languages but there are other languages such as Dart, Kotlin, etc. which can be compiled into JavaScript.
Compiling CoffeeScript into JavaScript usually results in JS that is fairly readable. You can convert snippets on the fly on the "Try CoffeeScript" tab of the CoffeeScript homepage, or via the CoffeeScript command line tool. There are also tools like decaffeinate that convert CoffeeScript source to modern JavaScript.
CoffeeScript is something that makes even good JavaScript code better. CoffeeScript compiled code can do everything that natively written JavaScript code can, only the code produced by using CoffeeScript is way shorter, and much easier to read.
See round_trip.coffee in CoffeeCoffee project (I'm the author):
I don't cover every case, but it's a start.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With