Skip to content

Commit

Permalink
fix: handle errors w/o file information.
Browse files Browse the repository at this point in the history
TypeScript errors do not always include file information, e.g. for
global errors triggered by incorrect compiler options.
  • Loading branch information
mprobst committed Jul 2, 2015
1 parent d1393b0 commit e69af1a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tools/broccoli/broccoli-typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,13 @@ class DiffingTSCompiler implements DiffingBroccoliPlugin {
let errorMessages = [];

allDiagnostics.forEach(diagnostic => {
var {line, character} = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
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) {
Expand Down

0 comments on commit e69af1a

Please sign in to comment.