Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 055a07e

Browse filesBrowse files
authored
Check for parse errors in emitted JS (microsoft#32009)
1 parent 3765651 commit 055a07e
Copy full SHA for 055a07e

2 files changed

+19-4Lines changed: 19 additions & 4 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/harness/harness.ts‎

Copy file name to clipboardExpand all lines: src/harness/harness.ts
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,6 +1311,13 @@ namespace Harness {
13111311
if (jsCode.length && jsCode.charCodeAt(jsCode.length - 1) !== ts.CharacterCodes.lineFeed) {
13121312
jsCode += "\r\n";
13131313
}
1314+
if (!result.diagnostics.length && !ts.endsWith(file.file, ts.Extension.Json)) {
1315+
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);
1316+
if (ts.length(fileParseResult.parseDiagnostics)) {
1317+
jsCode += getErrorBaseline([file.asTestFile()], fileParseResult.parseDiagnostics);
1318+
return;
1319+
}
1320+
}
13141321
jsCode += fileOutput(file, harnessSettings);
13151322
});
13161323

Collapse file

‎tests/baselines/reference/emitBOM.js‎

Copy file name to clipboardExpand all lines: tests/baselines/reference/emitBOM.js
+12-4Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,18 @@
22
// JS and d.ts output should have a BOM but not the sourcemap
33
var x;
44

5-
//// [emitBOM.js]
6-
// JS and d.ts output should have a BOM but not the sourcemap
7-
var x;
8-
//# sourceMappingURL=emitBOM.js.map
5+
tests/cases/compiler/emitBOM.js(1,2): error TS1127: Invalid character.
6+
tests/cases/compiler/emitBOM.js(1,3): error TS1127: Invalid character.
7+
8+
9+
==== tests/cases/compiler/emitBOM.js (2 errors) ====
10+
// JS and d.ts output should have a BOM but not the sourcemap
11+
12+
!!! error TS1127: Invalid character.
13+
14+
!!! error TS1127: Invalid character.
15+
var x;
16+
//# sourceMappingURL=emitBOM.js.map
917

1018
//// [emitBOM.d.ts]
1119
declare var x: any;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.