Skip to content

Commit b3731f1

Browse files
Merge pull request #1777 from Microsoft/emitCleanup
Cleanup emit code for comments.
2 parents a43bb47 + 3c5ff53 commit b3731f1

40 files changed

+379
-215
lines changed

src/compiler/emitter.ts

Lines changed: 99 additions & 73 deletions
Large diffs are not rendered by default.

tests/baselines/reference/arrowFunctionContexts.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ var __extends = this.__extends || function (d, b) {
103103
__.prototype = b.prototype;
104104
d.prototype = new __();
105105
};
106+
// Arrow function used in with statement
106107
with (window) {
107108
var p = function () { return this; };
108109
}
@@ -142,6 +143,7 @@ var M;
142143
// Repeat above for module members that are functions? (necessary to redo all of them?)
143144
var M2;
144145
(function (M2) {
146+
// Arrow function used in with statement
145147
with (window) {
146148
var p = function () { return this; };
147149
}

tests/baselines/reference/augmentedTypesEnum2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ var e2;
3131
(function (e2) {
3232
e2[e2["One"] = 0] = "One";
3333
})(e2 || (e2 = {}));
34-
;
34+
; // error
3535
var e2 = (function () {
3636
function e2() {
3737
}

tests/baselines/reference/augmentedTypesInterface.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,5 @@ var i3;
4747
(function (i3) {
4848
i3[i3["One"] = 0] = "One";
4949
})(i3 || (i3 = {}));
50-
;
50+
; // error
5151
//import i4 = require(''); // error

tests/baselines/reference/augmentedTypesModules.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,21 +124,21 @@ var m1d;
124124
var m1d = 1; // error
125125
function m2() {
126126
}
127-
;
127+
; // ok since the module is not instantiated
128128
var m2a;
129129
(function (m2a) {
130130
var y = 2;
131131
})(m2a || (m2a = {}));
132132
function m2a() {
133133
}
134-
;
134+
; // error since the module is instantiated
135135
var m2b;
136136
(function (m2b) {
137137
m2b.y = 2;
138138
})(m2b || (m2b = {}));
139139
function m2b() {
140140
}
141-
;
141+
; // error since the module is instantiated
142142
// should be errors to have function first
143143
function m2c() {
144144
}

tests/baselines/reference/augmentedTypesModules2.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,21 @@ module m2g { export class C { foo() { } } }
3131
//// [augmentedTypesModules2.js]
3232
function m2() {
3333
}
34-
;
34+
; // ok since the module is not instantiated
3535
var m2a;
3636
(function (m2a) {
3737
var y = 2;
3838
})(m2a || (m2a = {}));
3939
function m2a() {
4040
}
41-
;
41+
; // error since the module is instantiated
4242
var m2b;
4343
(function (m2b) {
4444
m2b.y = 2;
4545
})(m2b || (m2b = {}));
4646
function m2b() {
4747
}
48-
;
48+
; // error since the module is instantiated
4949
function m2c() {
5050
}
5151
;
@@ -59,7 +59,7 @@ var m2cc;
5959
})(m2cc || (m2cc = {}));
6060
function m2cc() {
6161
}
62-
;
62+
; // error to have module first
6363
function m2f() {
6464
}
6565
;

tests/baselines/reference/commaOperatorOtherValidOperation.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ function foo1<T1, T2>()
2222

2323

2424
//// [commaOperatorOtherValidOperation.js]
25+
//Comma operator in for loop
2526
for (var i = 0, j = 10; i < j; i++, j--) {
2627
}
2728
//Comma operator in fuction arguments and return

tests/baselines/reference/commentsOnObjectLiteral1.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@ var Person = makeClass(
88
);
99

1010
//// [commentsOnObjectLiteral1.js]
11-
var Person = makeClass({});
11+
var Person = makeClass(
12+
/**
13+
@scope Person
14+
*/
15+
{});

tests/baselines/reference/commentsVarDecl.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ var n = 30;
6666
/** var deckaration with comment on type as well*/
6767
var y = 20;
6868
/// var deckaration with comment on type as well
69-
var yy = 20;
69+
var yy =
70+
/// value comment
71+
20;
7072
/** comment2 */
7173
var z = function (x, y) { return x + y; };
7274
var z2;

tests/baselines/reference/constDeclarations-scopes.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ while (false) {
189189
label2: label3: label4: const c = 0;
190190
n = c;
191191
}
192+
// Try/catch/finally
192193
try {
193194
const c = 0;
194195
n = c;
@@ -201,12 +202,14 @@ finally {
201202
const c = 0;
202203
n = c;
203204
}
205+
// Switch
204206
switch (0) {
205207
case 0:
206208
const c = 0;
207209
n = c;
208210
break;
209211
}
212+
// blocks
210213
{
211214
const c = 0;
212215
n = c;

0 commit comments

Comments
 (0)