8000 Test cases to verify that declaration file is not emitted if any of t… · imskojs/TypeScript@a7b08dd · GitHub
[go: up one dir, main page]

Skip to content

Commit a7b08dd

Browse files
committed
Test cases to verify that declaration file is not emitted if any of the declaration file in program has error
1 parent e4110c3 commit a7b08dd

6 files changed

+131
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
tests/cases/compiler/declFile.d.ts(3,5): error TS1038: A 'declare' modifier cannot be used in an already ambient context.
2+
tests/cases/compiler/declFile.d.ts(4,5): error TS1038: A 'declare' modifier cannot be used in an already ambient context.
3+
tests/cases/compiler/declFile.d.ts(6,5): error TS1038: A 'declare' modifier cannot be used in an already ambient context.
4+
tests/cases/compiler/declFile.d.ts(8,5): error TS1038: A 'declare' modifier cannot be used in an already ambient context.
5+
6+
7+
==== tests/cases/compiler/client.ts (0 errors) ====
8+
///<reference path="declFile.d.ts"/>
9+
var x = new M.C(); // Declaration file wont get emitted because there are errors in declaration file
10+
11+
==== tests/cases/compiler/declFile.d.ts (4 errors) ====
12+
13+
declare module M {
14+
declare var x;
15+
~~~~~~~
16+
!!! error TS1038: A 'declare' modifier cannot be used in an already ambient context.
17+
declare function f();
18+
~~~~~~~
19+
!!! error TS1038: A 'declare' modifier cannot be used in an already ambient context.
20+
21+
declare module N { }
22+
~~~~~~~
23+
!!! error TS1038: A 'declare' modifier cannot be used in an already ambient context.
24+
25+
declare class C { }
26+
~~~~~~~
27+
!!! error TS1038: A 'declare' modifier cannot be used in an already ambient context.
28+
}
29+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//// [tests/cases/compiler/declFileWithErrorsInInputDeclarationFile.ts] ////
2+
3+
//// [declFile.d.ts]
4+
5+
declare module M {
6+
declare var x;
7+
declare function f();
8+
9+
declare module N { }
10+
11+
declare class C { }
12+
}
13+
14+
//// [client.ts]
15+
///<reference path="declFile.d.ts"/>
16+
var x = new M.C(); // Declaration file wont get emitted because there are errors in declaration file
17+
18+
19+
//// [client.js]
20+
///<reference path="declFile.d.ts"/>
21+
var x = new M.C(); // Declaration file wont get emitted because there are errors in declaration file
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
tests/cases/compiler/declFile.d.ts(3,5): error TS1038: A 'declare' modifier cannot be used in an already ambient context.
2+
tests/cases/compiler/declFile.d.ts(4,5): error TS1038: A 'declare' modifier cannot be used in an already ambient context.
3+
tests/cases/compiler/declFile.d.ts(6,5): error TS1038: A 'declare' modifier cannot be used in an already ambient context.
4+
tests/cases/compiler/declFile.d.ts(8,5): error TS1038: A 'declare' modifier cannot be used in an already ambient context.
5+
6+
7+
==== tests/cases/compiler/client.ts (0 errors) ====
8+
///<reference path="declFile.d.ts"/>
9+
var x = new M.C(); // Declaration file wont get emitted because there are errors in declaration file
10+
11+
==== tests/cases/compiler/declFile.d.ts (4 errors) ====
12+
13+
declare module M {
14+
declare var x;
15+
~~~~~~~
16+
!!! error TS1038: A 'declare' modifier cannot be used in an already ambient context.
17+
declare function f();
18+
~~~~~~~
19+
!!! error TS1038: A 'declare' modifier cannot be used in an already ambient context.
20+
21+
declare module N { }
22+
~~~~~~~
23+
!!! error TS1038: A 'declare' modifier cannot be used in an already ambient context.
24+
25+
declare class C { }
26+
~~~~~~~
27+
!!! error TS1038: A 'declare' modifier cannot be used in an already ambient context.
28+
}
29+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//// [tests/cases/compiler/declFileWithErrorsInInputDeclarationFileWithOut.ts] ////
2+
3+
//// [declFile.d.ts]
4+
5+
declare module M {
6+
declare var x;
7+
declare function f();
8+
9+
declare module N { }
10+
11+
declare class C { }
12+
}
13+
14+
//// [client.ts]
15+
///<reference path="declFile.d.ts"/>
16+
var x = new M.C(); // Declaration file wont get emitted because there are errors in declaration file
17+
18+
19+
//// [out.js]
20+
///<reference path="declFile.d.ts"/>
21+
var x = new M.C(); // Declaration file wont get emitted because there are errors in declaration file
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// @declaration: true
2+
3+
// @Filename: declFile.d.ts
4+
declare module M {
5+
declare var x;
6+
declare function f();
7+
8+
declare module N { }
9+
10+
declare class C { }
11+
}
12+
13+
// @Filename: client.ts
14+
///<reference path="declFile.d.ts"/>
15+
var x = new M.C(); // Declaration file wont get emitted because there are errors in declaration file
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// @declaration: true
2+
// @out: out.js
3+
4+
// @Filename: declFile.d.ts
5+
declare module M {
6+
declare var x;
7+
declare function f();
8+
9+
declare module N { }
10+
11+
declare class C { }
12+
}
13+
14+
// @Filename: client.ts
15+
///<reference path="declFile.d.ts"/>
16+
var x = new M.C(); // Declaration file wont get emitted because there are errors in declaration file

0 commit comments

Comments
 (0)
0