Created
November 2, 2012 09:00
-
-
Save moyhig/3999602 to your computer and use it in GitHub Desktop.
TypeScript Compiler, on-the-fly
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
Jaxer.Includer.load('http://requirejs.org/docs/release/2.1.1/minified/require.js'); | |
Jaxer.Includer.load('http://www.typescriptlang.org//Script/vs/languages/typescript/typescript.js'); | |
var ts = TypeScript; | |
var outfile = { | |
source: '', | |
Write: function(s) { this.source += s; }, | |
WriteLine: function(s) { this.source += s + "\r\n"; }, | |
Close: function() {}, | |
}; | |
var outerr = { | |
Write: function(s) {}, | |
WriteLine: function(s) {}, | |
Close: function() {}, | |
}; | |
var compiler = new ts.TypeScriptCompiler(outfile, outerr); | |
compiler.addUnit('var example = (a) => a;', 'example.ts'); | |
compiler.emit(false, function(){ return outfile;}); | |
var js = outfile.source; | |
document.write(js); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://kmaru.hatenablog.com/entry/2012/10/03/230008