I'm trying to do a slightly different thing than the example on the TypeScript compiler API wiki:
var host = ts.createCompilerHost(options);
var program = ts.createProgram(filenames, options, host);
var checker = ts.createTypeChecker(program, /*produceDiagnostics*/ true);
var result = checker.emitFiles();
The question is twofold:
1) how to make emitFiles to write to a specific path?
2) how to catch and handle compilation errors?