loose-ts-check
Version:
Run TS type-check and ignore certain errors in some files
28 lines (27 loc) • 906 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseTscErrors = void 0;
const tscErrorLineRegExp = /^(.*)\(\d+,\d+\): error (TS\d{4,}):.*$/;
const parseTscErrors = (tscOutput) => {
const tscErrors = [];
const tscOutputLines = tscOutput.filter((line) => line.trim() !== '');
let lastTscError;
tscOutputLines.forEach((line) => {
const errorLineMatch = line.match(tscErrorLineRegExp);
if (!errorLineMatch) {
if (lastTscError) {
lastTscError.rawErrorLines.push(line);
}
return;
}
const tscError = {
filePath: errorLineMatch[1],
tscErrorCode: errorLineMatch[2],
rawErrorLines: [line],
};
lastTscError = tscError;
tscErrors.push(tscError);
});
return tscErrors;
};
exports.parseTscErrors = parseTscErrors;