Skip to content

Instantly share code, notes, and snippets.

@moyhig
Created November 2, 2012 09:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moyhig/3999602 to your computer and use it in GitHub Desktop.
Save moyhig/3999602 to your computer and use it in GitHub Desktop.
TypeScript Compiler, on-the-fly
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);
@moyhig
Copy link
Author

moyhig commented Nov 2, 2012

@moyhig
Copy link
Author

moyhig commented Nov 2, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment