Emit comments for if statement

This commit is contained in:
Sheetal Nandi 2014-08-15 15:32:43 -07:00
parent 6036c92784
commit 0a75cc2926
6 changed files with 5 additions and 5 deletions

View file

@ -924,10 +924,6 @@ module ts {
}
function emitIfStatement(node: IfStatement) {
// emit comments only if this is not else if statement as else if will take care of emitting the leading/trailing comments
if (node.parent.kind !== SyntaxKind.IfStatement || (<IfStatement>node.parent).elseStatement !== node) {
emitLeadingComments(node);
}
emitLeadingComments(node);
var endPos = emitToken(SyntaxKind.IfKeyword, node.pos);
write(" ");
@ -937,7 +933,6 @@ module ts {
emitEmbeddedStatement(node.thenStatement);
if (node.elseStatement) {
writeLine();
emitLeadingComments(node.elseStatement);
emitToken(SyntaxKind.ElseKeyword, node.thenStatement.end);
if (node.elseStatement.kind === SyntaxKind.IfStatement) {
write(" ");

View file

@ -5,5 +5,6 @@ if (true) {
}
//// [commentOnIfStatement1.js]
// Test
if (true) {
}

View file

@ -218,6 +218,7 @@ var N;
}
N.F2 = F2;
})(N || (N = {}));
// literals
if (true) {
}
while (true) {

View file

@ -20,6 +20,7 @@ var foo;
})(foo || (foo = {}));
//// [foo_1.js]
define(["require", "exports", "./foo_0"], function (require, exports, foo) {
// Import should fail. foo_0 not an external module
if (foo.answer === 42) {
}
});

View file

@ -19,5 +19,6 @@ var s = (null);
var b = (n);
function isVoid() {
}
// Expected error: Values of type null and void cannot be compared
if (null === isVoid()) {
}

View file

@ -12,5 +12,6 @@ if (!null !== true) {
//// [voidAsOperator.js]
if (!void 0 !== true) {
}
//CHECK#2
if (!null !== true) {
}