Skip to content

Commit bb638db

Browse files
committed
Test cases for trailing comments for import declaration
1 parent 720fae1 commit bb638db

File tree

6 files changed

+241
-4
lines changed

6 files changed

+241
-4
lines changed

tests/baselines/reference/commentsExternalModules.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ var myvar2 = new m4.m2.c();
5454

5555
//// [commentsExternalModules_1.ts]
5656
/**This is on import declaration*/
57-
import extMod = require("commentsExternalModules_0");
57+
import extMod = require("commentsExternalModules_0"); // trailing comment1
5858
extMod.m1.fooExport();
5959
var newVar = new extMod.m1.m2.c();
6060
extMod.m4.fooExport();

tests/baselines/reference/commentsExternalModules2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ var myvar2 = new m4.m2.c();
5454

5555
//// [commentsExternalModules_1.ts]
5656
/**This is on import declaration*/
57-
import extMod = require("commentsExternalModules2_0");
57+
import extMod = require("commentsExternalModules2_0"); // trailing comment 1
5858
extMod.m1.fooExport();
5959
export var newVar = new extMod.m1.m2.c();
6060
extMod.m4.fooExport();
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
//// [tests/cases/compiler/commentsExternalModules3.ts] ////
2+
3+
//// [commentsExternalModules2_0.ts]
4+
5+
/** Module comment*/
6+
export module m1 {
7+
/** b's comment*/
8+
export var b: number;
9+
/** foo's comment*/
10+
function foo() {
11+
return b;
12+
}
13+
/** m2 comments*/
14+
export module m2 {
15+
/** class comment;*/
16+
export class c {
17+
};
18+
/** i*/
19+
export var i = new c();
20+
}
21+
/** exported function*/
22+
export function fooExport() {
23+
return foo();
24+
}
25+
}
26+
m1.fooExport();
27+
var myvar = new m1.m2.c();
28+
29+
/** Module comment */
30+
export module m4 {
31+
/** b's comment */
32+
export var b: number;
33+
/** foo's comment
34+
*/
35+
function foo() {
36+
return b;
37+
}
38+
/** m2 comments
39+
*/
40+
export module m2 {
41+
/** class comment; */
42+
export class c {
43+
};
44+
/** i */
45+
export var i = new c();
46+
}
47+
/** exported function */
48+
export function fooExport() {
49+
return foo();
50+
}
51+
}
52+
m4.fooExport();
53+
var myvar2 = new m4.m2.c();
54+
55+
//// [commentsExternalModules_1.ts]
56+
/**This is on import declaration*/
57+
import extMod = require("commentsExternalModules2_0"); // trailing comment 1
58+
extMod.m1.fooExport();
59+
export var newVar = new extMod.m1.m2.c();
60+
extMod.m4.fooExport();
61+
export var newVar2 = new extMod.m4.m2.c();
62+
63+
64+
//// [commentsExternalModules2_0.js]
65+
/** Module comment*/
66+
(function (m1) {
67+
/** b's comment*/
68+
m1.b;
69+
/** foo's comment*/
70+
function foo() {
71+
return m1.b;
72+
}
73+
/** m2 comments*/
74+
(function (m2) {
75+
/** class comment;*/
76+
var c = (function () {
77+
function c() {
78+
}
79+
return c;
80+
})();
81+
m2.c = c;
82+
;
83+
/** i*/
84+
m2.i = new c();
85+
})(m1.m2 || (m1.m2 = {}));
86+
var m2 = m1.m2;
87+
/** exported function*/
88+
function fooExport() {
89+
return foo();
90+
}
91+
m1.fooExport = fooExport;
92+
})(exports.m1 || (exports.m1 = {}));
93+
var m1 = exports.m1;
94+
m1.fooExport();
95+
var myvar = new m1.m2.c();
96+
/** Module comment */
97+
(function (m4) {
98+
/** b's comment */
99+
m4.b;
100+
/** foo's comment
101+
*/
102+
function foo() {
103+
return m4.b;
104+
}
105+
/** m2 comments
106+
*/
107+
(function (m2) {
108+
/** class comment; */
109+
var c = (function () {
110+
function c() {
111+
}
112+
return c;
113+
})();
114+
m2.c = c;
115+
;
116+
/** i */
117+
m2.i = new c();
118+
})(m4.m2 || (m4.m2 = {}));
119+
var m2 = m4.m2;
120+
/** exported function */
121+
function fooExport() {
122+
return foo();
123+
}
124+
m4.fooExport = fooExport;
125+
})(exports.m4 || (exports.m4 = {}));
126+
var m4 = exports.m4;
127+
m4.fooExport();
128+
var myvar2 = new m4.m2.c();
129+
//// [commentsExternalModules_1.js]
130+
/**This is on import declaration*/
131+
var extMod = require("commentsExternalModules2_0"); // trailing comment 1
132+
extMod.m1.fooExport();
133+
exports.newVar = new extMod.m1.m2.c();
134+
extMod.m4.fooExport();
135+
exports.newVar2 = new extMod.m4.m2.c();
136+
137+
138+
//// [commentsExternalModules2_0.d.ts]
139+
/** Module comment*/
140+
export declare module m1 {
141+
/** b's comment*/
142+
var b: number;
143+
/** m2 comments*/
144+
module m2 {
145+
/** class comment;*/
146+
class c {
147+
}
148+
/** i*/
149+
var i: c;
150+
}
151+
/** exported function*/
152+
function fooExport(): number;
153+
}
154+
/** Module comment */
155+
export declare module m4 {
156+
/** b's comment */
157+
var b: number;
158+
/** m2 comments
159+
*/
160+
module m2 {
161+
/** class comment; */
162+
class c {
163+
}
164+
/** i */
165+
var i: c;
166+
}
167+
/** exported function */
168+
function fooExport(): number;
169+
}
170+
//// [commentsExternalModules_1.d.ts]
171+
/**This is on import declaration*/
172+
import extMod = require("commentsExternalModules2_0");
173+
export declare var newVar: extMod.m1.m2.c;
174+
export declare var newVar2: extMod.m4.m2.c;

tests/cases/compiler/commentsExternalModules.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ var myvar2 = new m4.m2.c();
5656

5757
// @Filename: commentsExternalModules_1.ts
5858
/**This is on import declaration*/
59-
import extMod = require("commentsExternalModules_0");
59+
import extMod = require("commentsExternalModules_0"); // trailing comment1
6060
extMod.m1.fooExport();
6161
var newVar = new extMod.m1.m2.c();
6262
extMod.m4.fooExport();

tests/cases/compiler/commentsExternalModules2.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ var myvar2 = new m4.m2.c();
5656

5757
// @Filename: commentsExternalModules_1.ts
5858
/**This is on import declaration*/
59-
import extMod = require("commentsExternalModules2_0");
59+
import extMod = require("commentsExternalModules2_0"); // trailing comment 1
6060
extMod.m1.fooExport();
6161
export var newVar = new extMod.m1.m2.c();
6262
extMod.m4.fooExport();
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
//@module: commonjs
2+
// @target: ES5
3+
// @declaration: true
4+
// @comments: true
5+
6+
// @Filename: commentsExternalModules2_0.ts
7+
/** Module comment*/
8+
export module m1 {
9+
/** b's comment*/
10+
export var b: number;
11+
/** foo's comment*/
12+
function foo() {
13+
return b;
14+
}
15+
/** m2 comments*/
16+
export module m2 {
17+
/** class comment;*/
18+
export class c {
19+
};
20+
/** i*/
21+
export var i = new c();
22+
}
23+
/** exported function*/
24+
export function fooExport() {
25+
return foo();
26+
}
27+
}
28+
m1.fooExport();
29+
var myvar = new m1.m2.c();
30+
31+
/** Module comment */
32+
export module m4 {
33+
/** b's comment */
34+
export var b: number;
35+
/** foo's comment
36+
*/
37+
function foo() {
38+
return b;
39+
}
40+
/** m2 comments
41+
*/
42+
export module m2 {
43+
/** class comment; */
44+
export class c {
45+
};
46+
/** i */
47+
export var i = new c();
48+
}
49+
/** exported function */
50+
export function fooExport() {
51+
return foo();
52+
}
53+
}
54+
m4.fooExport();
55+
var myvar2 = new m4.m2.c();
56+
57+
// @Filename: commentsExternalModules_1.ts
58+
/**This is on import declaration*/
59+
import extMod = require("commentsExternalModules2_0"); // trailing comment 1
60+
extMod.m1.fooExport();
61+
export var newVar = new extMod.m1.m2.c();
62+
extMod.m4.fooExport();
63+
export var newVar2 = new extMod.m4.m2.c();

0 commit comments

Comments
 (0)