mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
Check for parse errors in emitted JS (#32009)
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
|
||||
@@ -2,10 +2,18 @@
|
||||
// JS and d.ts output should have a BOM but not the sourcemap
|
||||
var x;
|
||||
|
||||
//// [emitBOM.js]
|
||||
// JS and d.ts output should have a BOM but not the sourcemap
|
||||
var x;
|
||||
//# sourceMappingURL=emitBOM.js.map
|
||||
tests/cases/compiler/emitBOM.js(1,2): error TS1127: Invalid character.
|
||||
tests/cases/compiler/emitBOM.js(1,3): error TS1127: Invalid character.
|
||||
|
||||
|
||||
==== tests/cases/compiler/emitBOM.js (2 errors) ====
|
||||
// JS and d.ts output should have a BOM but not the sourcemap
|
||||
|
||||
!!! error TS1127: Invalid character.
|
||||
|
||||
!!! error TS1127: Invalid character.
|
||||
var x;
|
||||
//# sourceMappingURL=emitBOM.js.map
|
||||
|
||||
//// [emitBOM.d.ts]
|
||||
declare var x: any;
|
||||
|
||||
Reference in New Issue
Block a user