dts-bundle-generator
Version:
DTS Bundle Generator
26 lines (25 loc) • 1.09 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var ts = require("typescript");
var logger_1 = require("./logger");
function checkProgramDiagnosticsErrors(program) {
checkDiagnosticsErrors(ts.getPreEmitDiagnostics(program));
checkDiagnosticsErrors(program.getDeclarationDiagnostics());
}
exports.checkProgramDiagnosticsErrors = checkProgramDiagnosticsErrors;
function checkDiagnosticsErrors(diagnostics) {
var errors = [];
diagnostics.forEach(function (diagnostic) {
if (!diagnostic.file) {
return;
}
var _a = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start), line = _a.line, character = _a.character;
var message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
errors.push(diagnostic.file.fileName + "(" + (line + 1) + "," + (character + 1) + "): TS" + diagnostic.code + ": " + message);
});
if (errors.length === 0) {
return;
}
logger_1.errorLog(errors.join('\n'));
throw new Error('Compile with errors');
}