Skip to content

Commit e69af1a

Browse files
committed
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.
1 parent d1393b0 commit e69af1a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tools/broccoli/broccoli-typescript.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,13 @@ class DiffingTSCompiler implements DiffingBroccoliPlugin {
137137
let errorMessages = [];
138138

139139
allDiagnostics.forEach(diagnostic => {
140-
var {line, character} = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
140+
var pos = '';
141+
if (diagnostic.file) {
142+
var {line, character} = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
143+
pos = `${diagnostic.file.fileName} (${line + 1}, ${character + 1}): `
144+
}
141145
var message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
142-
errorMessages.push(
143-
` ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
146+
errorMessages.push(` ${pos}${message}`);
144147
});
145148

146149
if (errorMessages.length) {

0 commit comments

Comments
 (0)