Skip to content

Commit 4c1397b

Browse files
committed
Added test for noEmitOnError
1 parent e4f5756 commit 4c1397b

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

Diff for: src/harness/compilerRunner.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,12 @@ class CompilerBaselineRunner extends RunnerBase {
175175
it('Correct sourcemap content for ' + fileName, () => {
176176
if (options.sourceMap) {
177177
Harness.Baseline.runBaseline('Correct sourcemap content for ' + fileName, justName.replace(/\.ts$/, '.sourcemap.txt'), () => {
178-
return result.getSourceMapRecord();
178+
var record = result.getSourceMapRecord();
179+
if (options.noEmitOnError && result.errors.length !== 0 && record === undefined) {
180+
// Because of the noEmitOnError option no files are created. We need to return null because baselining isn't required.
181+
return null;
182+
}
183+
return record;
179184
});
180185
}
181186
});
@@ -246,6 +251,12 @@ class CompilerBaselineRunner extends RunnerBase {
246251
}
247252

248253
Harness.Baseline.runBaseline('Correct Sourcemap output for ' + fileName, justName.replace(/\.ts/, '.js.map'), () => {
254+
if (options.noEmitOnError && result.errors.length !== 0 && result.sourceMaps.length === 0) {
255+
// We need to return null here or the runBaseLine will actually create a empty file.
256+
// Baselining isn't required here because there is no output.
257+
return null;
258+
}
259+
249260
var sourceMapCode = '';
250261
for (var i = 0; i < result.sourceMaps.length; i++) {
251262
sourceMapCode += '//// [' + Harness.Path.getFileName(result.sourceMaps[i].fileName) + ']\r\n';

Diff for: src/harness/harness.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,10 @@ module Harness {
703703
}
704704
break;
705705

706+
case 'noemitonerror':
707+
options.noEmitOnError = !!setting.value;
708+
break;
709+
706710
case 'noresolve':
707711
options.noResolve = !!setting.value;
708712
break;
@@ -1145,7 +1149,7 @@ module Harness {
11451149
var optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines
11461150

11471151
// List of allowed metadata names
1148-
var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noimplicitany", "noresolve", "newline", "newlines", "emitbom", "errortruncation", "usecasesensitivefilenames"];
1152+
var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noemitonerror", "noimplicitany", "noresolve", "newline", "newlines", "emitbom", "errortruncation", "usecasesensitivefilenames"];
11491153

11501154
function extractCompilerSettings(content: string): CompilerSetting[] {
11511155

Diff for: tests/baselines/reference/noEmitOnError.errors.txt

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
tests/cases/compiler/noEmitOnError.ts(2,5): error TS2323: Type 'string' is not assignable to type 'number'.
2+
3+
4+
==== tests/cases/compiler/noEmitOnError.ts (1 errors) ====
5+
6+
var x: number = "";
7+
~
8+
!!! error TS2323: Type 'string' is not assignable to type 'number'.
9+

Diff for: tests/cases/compiler/noEmitOnError.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// @noemitonerror: true
2+
// @sourcemap: true
3+
// @declaration: true
4+
5+
var x: number = "";

0 commit comments

Comments
 (0)