Skip to content

Commit 0a75cc2

Browse files
committed
Emit comments for if statement
1 parent 6036c92 commit 0a75cc2

File tree

6 files changed

+5
-5
lines changed

6 files changed

+5
-5
lines changed

src/compiler/emitter.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -924,10 +924,6 @@ module ts {
924924
}
925925

926926
function emitIfStatement(node: IfStatement) {
927-
// emit comments only if this is not else if statement as else if will take care of emitting the leading/trailing comments
928-
if (node.parent.kind !== SyntaxKind.IfStatement || (<IfStatement>node.parent).elseStatement !== node) {
929-
emitLeadingComments(node);
930-
}
931927
emitLeadingComments(node);
932928
var endPos = emitToken(SyntaxKind.IfKeyword, node.pos);
933929
write(" ");
@@ -937,7 +933,6 @@ module ts {
937933
emitEmbeddedStatement(node.thenStatement);
938934
if (node.elseStatement) {
939935
writeLine();
940-
emitLeadingComments(node.elseStatement);
941936
emitToken(SyntaxKind.ElseKeyword, node.thenStatement.end);
942937
if (node.elseStatement.kind === SyntaxKind.IfStatement) {
943938
write(" ");

tests/baselines/reference/commentOnIfStatement1.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ if (true) {
55
}
66

77
//// [commentOnIfStatement1.js]
8+
// Test
89
if (true) {
910
}

tests/baselines/reference/ifDoWhileStatements.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ var N;
218218
}
219219
N.F2 = F2;
220220
})(N || (N = {}));
221+
// literals
221222
if (true) {
222223
}
223224
while (true) {

tests/baselines/reference/importNonExternalModule.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ var foo;
2020
})(foo || (foo = {}));
2121
//// [foo_1.js]
2222
define(["require", "exports", "./foo_0"], function (require, exports, foo) {
23+
// Import should fail. foo_0 not an external module
2324
if (foo.answer === 42) {
2425
}
2526
});

tests/baselines/reference/literals-negative.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ var s = (null);
1919
var b = (n);
2020
function isVoid() {
2121
}
22+
// Expected error: Values of type null and void cannot be compared
2223
if (null === isVoid()) {
2324
}

tests/baselines/reference/voidAsOperator.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ if (!null !== true) {
1212
//// [voidAsOperator.js]
1313
if (!void 0 !== true) {
1414
}
15+
//CHECK#2
1516
if (!null !== true) {
1617
}

0 commit comments

Comments
 (0)