Check for parse errors in emitted JS (#32009)

This commit is contained in:
Wesley Wigham
2019-07-01 14:15:30 -07:00
committed by GitHub
parent 3765651d82
commit 055a07ea4a
2 changed files with 19 additions and 4 deletions

View File

@@ -1311,6 +1311,13 @@ namespace Harness {
if (jsCode.length && jsCode.charCodeAt(jsCode.length - 1) !== ts.CharacterCodes.lineFeed) {
jsCode += "\r\n";
}
if (!result.diagnostics.length && !ts.endsWith(file.file, ts.Extension.Json)) {
const fileParseResult = ts.createSourceFile(file.file, file.text, options.target || ts.ScriptTarget.ES3, /*parentNodes*/ false, ts.endsWith(file.file, "x") ? ts.ScriptKind.JSX : ts.ScriptKind.JS);
if (ts.length(fileParseResult.parseDiagnostics)) {
jsCode += getErrorBaseline([file.asTestFile()], fileParseResult.parseDiagnostics);
return;
}
}
jsCode += fileOutput(file, harnessSettings);
});