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:
parent
d1393b0581
commit
e69af1a3cd
|
@ -137,10 +137,13 @@ class DiffingTSCompiler implements DiffingBroccoliPlugin {
|
||||||
let errorMessages = [];
|
let errorMessages = [];
|
||||||
|
|
||||||
allDiagnostics.forEach(diagnostic => {
|
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');
|
var message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
|
||||||
errorMessages.push(
|
errorMessages.push(` ${pos}${message}`);
|
||||||
` ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (errorMessages.length) {
|
if (errorMessages.length) {
|
||||||
|
|
Loading…
Reference in New Issue