Skip to content

Instantly share code, notes, and snippets.

@pvdz
Created January 14, 2013 09:50
Show Gist options
  • Save pvdz/4528967 to your computer and use it in GitHub Desktop.
Save pvdz/4528967 to your computer and use it in GitHub Desktop.
Minimal TypeScript compile case. Ouch..
function compile(source) { // derived from www.typescriptlang.org/Playground/
var result = '';
var outfile = {Write:function(s){ result += s; }, WriteLine:function(s){ result += s + '\n'; }, Close:function(){}};
var compiler = new TypeScript.TypeScriptCompiler();
compiler.setErrorCallback(function(start, len, message) { console.log('error',arguments); });
compiler.parser.errorRecovery = true;
compiler.addUnit(source, "input.ts");
compiler.emit(function createFile(fileName) { return outfile; });
return result;
}
@pvdz
Copy link
Author

pvdz commented Jan 14, 2013

Also. What's up with the capitalized methods? :'(

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