Skip to content

Commit a87dae1

Browse files
committed
Verify that when emit blocking error occurs rest of the emit occurs as expected
1 parent 5e14edb commit a87dae1

7 files changed

Lines changed: 118 additions & 1 deletion

src/harness/compilerRunner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class CompilerBaselineRunner extends RunnerBase {
151151
});
152152

153153
it("Correct JS output for " + fileName, () => {
154-
if (!ts.fileExtensionIs(lastUnit.name, "d.ts") && this.emit) {
154+
if (!(units.length === 1 && ts.fileExtensionIs(lastUnit.name, "d.ts")) && this.emit) {
155155
if (result.files.length === 0 && result.errors.length === 0) {
156156
throw new Error("Expected at least one js file to be emitted or at least one error to be created.");
157157
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//// [tests/cases/compiler/fileReferencesWithNoExtensions.ts] ////
2+
3+
//// [t.ts]
4+
/// <reference path="a"/>
5+
/// <reference path="b"/>
6+
/// <reference path="c"/>
7+
var a = aa; // Check that a.ts is referenced
8+
var b = bb; // Check that b.d.ts is referenced
9+
var c = cc; // Check that c.ts has precedence over c.d.ts
10+
11+
//// [a.ts]
12+
var aa = 1;
13+
14+
//// [b.d.ts]
15+
declare var bb: number;
16+
17+
//// [c.ts]
18+
var cc = 1;
19+
20+
//// [c.d.ts]
21+
declare var xx: number;
22+
23+
24+
//// [a.js]
25+
var aa = 1;
26+
//// [c.js]
27+
var cc = 1;
28+
//// [t.js]
29+
/// <reference path="a"/>
30+
/// <reference path="b"/>
31+
/// <reference path="c"/>
32+
var a = aa; // Check that a.ts is referenced
33+
var b = bb; // Check that b.d.ts is referenced
34+
var c = cc; // Check that c.ts has precedence over c.d.ts
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error TS5055: Cannot write file 'tests/cases/compiler/a.js' which is one of the input files.
2+
3+
4+
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' which is one of the input files.
5+
==== tests/cases/compiler/a.ts (0 errors) ====
6+
class c {
7+
}
8+
9+
==== tests/cases/compiler/b.ts (0 errors) ====
10+
// this should be emitted
11+
class d {
12+
}
13+
14+
==== tests/cases/compiler/a.js (0 errors) ====
15+
function foo() {
16+
}
17+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//// [tests/cases/compiler/jsFileCompilationEmitBlockedCorrectly.ts] ////
2+
3+
//// [a.ts]
4+
class c {
5+
}
6+
7+
//// [b.ts]
8+
// this should be emitted
9+
class d {
10+
}
11+
12+
//// [a.js]
13+
function foo() {
14+
}
15+
16+
17+
//// [b.js]
18+
// this should be emitted
19+
var d = (function () {
20+
function d() {
21+
}
22+
return d;
23+
})();
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//// [tests/cases/compiler/jsFileCompilationWithDeclarationEmitPathSameAsInput.ts] ////
2+
3+
//// [a.ts]
4+
class c {
5+
}
6+
7+
//// [a.d.ts]
8+
declare function isC(): boolean;
9+
10+
//// [a.js]
11+
var c = (function () {
12+
function c() {
13+
}
14+
return c;
15+
})();
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//// [tests/cases/compiler/jsFileCompilationWithOutDeclarationFileNameSameAsInputJsFile.ts] ////
2+
3+
//// [a.ts]
4+
class c {
5+
}
6+
7+
//// [b.d.ts]
8+
declare function foo(): boolean;
9+
10+
//// [b.js]
11+
var c = (function () {
12+
function c() {
13+
}
14+
return c;
15+
})();
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// @jsExtensions: js
2+
// @filename: a.ts
3+
class c {
4+
}
5+
6+
// @filename: b.ts
7+
// this should be emitted
8+
class d {
9+
}
10+
11+
// @filename: a.js
12+
function foo() {
13+
}

0 commit comments

Comments
 (0)