- npm install
- node index.js
Last active
October 30, 2015 20:41
-
-
Save diverted247/30c102020ffb576f3534 to your computer and use it in GitHub Desktop.
Compiling TypeScript string within Nodejs Including Diagnostics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ts = require("typescript"); | |
var content = | |
"import {f} from \"foo\"\n" + | |
"export var x = f()"; | |
var compilerOptions = { module: ts.ModuleKind.CommonJS }; | |
var res = ts.transpileModule( content , { compilerOptions: compilerOptions , moduleName: "myModule2" , reportDiagnostics:true } ); | |
console.dir( res ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "ts-compile", | |
"version": "1.0.0", | |
"description": "Compiling TypeScript string within Nodejs Including Diagnostics", | |
"main": "index.js", | |
"devDependencies": { | |
"typescript":"1.6.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment