Verify that when emit blocking error occurs rest of the emit occurs as expected

This commit is contained in:
Sheetal Nandi
2015-10-12 12:44:21 -07:00
parent 5e14edb4b7
commit a87dae15a9
7 changed files with 118 additions and 1 deletions

View File

@@ -151,7 +151,7 @@ class CompilerBaselineRunner extends RunnerBase {
});
it("Correct JS output for " + fileName, () => {
if (!ts.fileExtensionIs(lastUnit.name, "d.ts") && this.emit) {
if (!(units.length === 1 && ts.fileExtensionIs(lastUnit.name, "d.ts")) && this.emit) {
if (result.files.length === 0 && result.errors.length === 0) {
throw new Error("Expected at least one js file to be emitted or at least one error to be created.");
}

View File

@@ -0,0 +1,34 @@
//// [tests/cases/compiler/fileReferencesWithNoExtensions.ts] ////
//// [t.ts]
/// <reference path="a"/>
/// <reference path="b"/>
/// <reference path="c"/>
var a = aa; // Check that a.ts is referenced
var b = bb; // Check that b.d.ts is referenced
var c = cc; // Check that c.ts has precedence over c.d.ts
//// [a.ts]
var aa = 1;
//// [b.d.ts]
declare var bb: number;
//// [c.ts]
var cc = 1;
//// [c.d.ts]
declare var xx: number;
//// [a.js]
var aa = 1;
//// [c.js]
var cc = 1;
//// [t.js]
/// <reference path="a"/>
/// <reference path="b"/>
/// <reference path="c"/>
var a = aa; // Check that a.ts is referenced
var b = bb; // Check that b.d.ts is referenced
var c = cc; // Check that c.ts has precedence over c.d.ts

View File

@@ -0,0 +1,17 @@
error TS5055: Cannot write file 'tests/cases/compiler/a.js' which is one of the input files.
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' which is one of the input files.
==== tests/cases/compiler/a.ts (0 errors) ====
class c {
}
==== tests/cases/compiler/b.ts (0 errors) ====
// this should be emitted
class d {
}
==== tests/cases/compiler/a.js (0 errors) ====
function foo() {
}

View File

@@ -0,0 +1,23 @@
//// [tests/cases/compiler/jsFileCompilationEmitBlockedCorrectly.ts] ////
//// [a.ts]
class c {
}
//// [b.ts]
// this should be emitted
class d {
}
//// [a.js]
function foo() {
}
//// [b.js]
// this should be emitted
var d = (function () {
function d() {
}
return d;
})();

View File

@@ -0,0 +1,15 @@
//// [tests/cases/compiler/jsFileCompilationWithDeclarationEmitPathSameAsInput.ts] ////
//// [a.ts]
class c {
}
//// [a.d.ts]
declare function isC(): boolean;
//// [a.js]
var c = (function () {
function c() {
}
return c;
})();

View File

@@ -0,0 +1,15 @@
//// [tests/cases/compiler/jsFileCompilationWithOutDeclarationFileNameSameAsInputJsFile.ts] ////
//// [a.ts]
class c {
}
//// [b.d.ts]
declare function foo(): boolean;
//// [b.js]
var c = (function () {
function c() {
}
return c;
})();

View File

@@ -0,0 +1,13 @@
// @jsExtensions: js
// @filename: a.ts
class c {
}
// @filename: b.ts
// this should be emitted
class d {
}
// @filename: a.js
function foo() {
}