Merge pull request #8095 from Microsoft/transformArrowComments

[Transforms] Fixes the incorrectly assigned arrow expression trailing comments
This commit is contained in:
Sheetal Nandi 2016-04-14 13:19:24 -07:00
commit 1c06342ddb
3 changed files with 7 additions and 5 deletions

View file

@ -1505,8 +1505,11 @@ const _super = (function (geti, seti) {
const endingLine = writer.getLine();
emitLexicalEnvironment(endLexicalEnvironment(), /*newLine*/ startingLine !== endingLine);
const range = collapseRangeToEnd(body.statements);
emitLeadingComments(range, getLeadingComments(range));
// Do not emit leading comments if the body belongs to arrow expression
if (!body.original || isBlock(body.original)) {
const range = collapseRangeToEnd(body.statements);
emitLeadingComments(range, getLeadingComments(range));
}
decreaseIndent();
}

View file

@ -1271,6 +1271,7 @@ namespace ts {
setNodeEmitFlags(block, NodeEmitFlags.SingleLine);
}
setOriginalNode(block, node.body);
return block;
}

View file

@ -110,9 +110,7 @@ var f8 = function (x, y, z) {
var f9 = function (a) { return a; };
var f10 = function (a) { return a; };
var f11 = function (a) { return a; };
var f12 = function (a) {
return a;
};
var f12 = function (a) { return a; };
// Should be valid.
var f11 = function (a) { return a; };
// Should be valid.