mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-10 21:07:52 -05:00
Added test for noEmitOnError
This commit is contained in:
@@ -175,7 +175,12 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
it('Correct sourcemap content for ' + fileName, () => {
|
||||
if (options.sourceMap) {
|
||||
Harness.Baseline.runBaseline('Correct sourcemap content for ' + fileName, justName.replace(/\.ts$/, '.sourcemap.txt'), () => {
|
||||
return result.getSourceMapRecord();
|
||||
var record = result.getSourceMapRecord();
|
||||
if (options.noEmitOnError && result.errors.length !== 0 && record === undefined) {
|
||||
// Because of the noEmitOnError option no files are created. We need to return null because baselining isn't required.
|
||||
return null;
|
||||
}
|
||||
return record;
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -246,6 +251,12 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
}
|
||||
|
||||
Harness.Baseline.runBaseline('Correct Sourcemap output for ' + fileName, justName.replace(/\.ts/, '.js.map'), () => {
|
||||
if (options.noEmitOnError && result.errors.length !== 0 && result.sourceMaps.length === 0) {
|
||||
// We need to return null here or the runBaseLine will actually create a empty file.
|
||||
// Baselining isn't required here because there is no output.
|
||||
return null;
|
||||
}
|
||||
|
||||
var sourceMapCode = '';
|
||||
for (var i = 0; i < result.sourceMaps.length; i++) {
|
||||
sourceMapCode += '//// [' + Harness.Path.getFileName(result.sourceMaps[i].fileName) + ']\r\n';
|
||||
|
||||
@@ -703,6 +703,10 @@ module Harness {
|
||||
}
|
||||
break;
|
||||
|
||||
case 'noemitonerror':
|
||||
options.noEmitOnError = !!setting.value;
|
||||
break;
|
||||
|
||||
case 'noresolve':
|
||||
options.noResolve = !!setting.value;
|
||||
break;
|
||||
@@ -1145,7 +1149,7 @@ module Harness {
|
||||
var optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines
|
||||
|
||||
// List of allowed metadata names
|
||||
var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noimplicitany", "noresolve", "newline", "newlines", "emitbom", "errortruncation", "usecasesensitivefilenames"];
|
||||
var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noemitonerror", "noimplicitany", "noresolve", "newline", "newlines", "emitbom", "errortruncation", "usecasesensitivefilenames"];
|
||||
|
||||
function extractCompilerSettings(content: string): CompilerSetting[] {
|
||||
|
||||
|
||||
9
tests/baselines/reference/noEmitOnError.errors.txt
Normal file
9
tests/baselines/reference/noEmitOnError.errors.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
tests/cases/compiler/noEmitOnError.ts(2,5): error TS2323: Type 'string' is not assignable to type 'number'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/noEmitOnError.ts (1 errors) ====
|
||||
|
||||
var x: number = "";
|
||||
~
|
||||
!!! error TS2323: Type 'string' is not assignable to type 'number'.
|
||||
|
||||
5
tests/cases/compiler/noEmitOnError.ts
Normal file
5
tests/cases/compiler/noEmitOnError.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
// @noemitonerror: true
|
||||
// @sourcemap: true
|
||||
// @declaration: true
|
||||
|
||||
var x: number = "";
|
||||
Reference in New Issue
Block a user