Is there a way to compile a String containing TypeScript to its JavaScript String equivalent ?
For instance, in Coffeescript (and LiveScript, coco etc) its a (simplified) one-liner:
jsCompiledCode = require('coffee-script').compile('do -> console.log "Hello world"', {bare:true});
Can something similar be implemented for TypeScript, preferably without involving the filesystem ? Are there any implications with referencing other modules that would have to be resolved at compile time ?
You can use TypeScript.Api nodejs package : https://npmjs.org/package/typescript.api
In particular check out this function : https://github.com/sinclairzx81/typescript.api#compile
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