fix: handle errors w/o file information.

TypeScript errors do not always include file information, e.g. for
global errors triggered by incorrect compiler options.
This commit is contained in:
Martin Probst 2015-06-26 14:43:51 -07:00
parent d1393b0581
commit e69af1a3cd
1 changed files with 6 additions and 3 deletions

View File

@ -137,10 +137,13 @@ class DiffingTSCompiler implements DiffingBroccoliPlugin {
let errorMessages = [];
allDiagnostics.forEach(diagnostic => {
var pos = '';
if (diagnostic.file) {
var {line, character} = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
pos = `${diagnostic.file.fileName} (${line + 1}, ${character + 1}): `
}
var message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
errorMessages.push(
` ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
errorMessages.push(` ${pos}${message}`);
});
if (errorMessages.length) {