以编程方式将TypeScript字符串编译为Javascript字符串 [英] Compile a TypeScript String to a Javascript String programmatically
问题描述
是否有一种方法可以将包含TypeScript的 String 编译为其 String 等效项?
Is there a way to compile a String containing TypeScript to its JavaScript String equivalent ?
,在Coffeescript(和LiveScript,coco等)它的(简化)一行:
For instance, in Coffeescript (and LiveScript, coco etc) its a (simplified) one-liner:
jsCompiledCode = require -script')。compile('do - > console.logHello world',{bare:true});
可以为TypeScript实现类似的东西,最好不涉及文件系统?
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 ?
推荐答案
您可以使用TypeScript.Api nodejs包: https://npmjs.org/package/typescript.api
You can use TypeScript.Api nodejs package : https://npmjs.org/package/typescript.api
特别查看此功能: https://github.com /sinclairzx81/typescript.api#compile
这篇关于以编程方式将TypeScript字符串编译为Javascript字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!