Emit leading comments for '}' of the constructor block

Fixes #503
This commit is contained in:
Sheetal Nandi 2014-08-21 17:17:32 -07:00
parent 45e76e2bd2
commit 53d79a25d3
9 changed files with 47 additions and 1 deletions

View File

@ -1652,8 +1652,11 @@ module ts {
if (superCall) statements = statements.slice(1);
emitLines(statements);
}
decreaseIndent();
writeLine();
if (ctor) {
emitLeadingCommentsOfPosition((<Block>ctor.body).statements.end);
}
decreaseIndent();
emitToken(SyntaxKind.CloseBraceToken, ctor ? (<Block>ctor.body).statements.end : node.members.end);
scopeEmitEnd();
emitEnd(<Node>ctor || node);

View File

@ -20,6 +20,7 @@ Foo();
//// [callOverloads1.js]
var Foo = (function () {
function Foo(x) {
// WScript.Echo("Constructor function has executed");
}
Foo.prototype.bar1 = function () {
};

View File

@ -28,6 +28,7 @@ Foo();
//// [callOverloads2.js]
var Foo = (function () {
function Foo(x) {
// WScript.Echo("Constructor function has executed");
}
Foo.prototype.bar1 = function () {
};

View File

@ -21,6 +21,7 @@ Foo("s");
//// [callOverloads3.js]
var Foo = (function () {
function Foo(x) {
// WScript.Echo("Constructor function has executed");
}
Foo.prototype.bar1 = function () {
};

View File

@ -21,6 +21,7 @@ Foo("s");
//// [callOverloads4.js]
var Foo = (function () {
function Foo(x) {
// WScript.Echo("Constructor function has executed");
}
Foo.prototype.bar1 = function () {
};

View File

@ -22,6 +22,7 @@ Foo("s");
//// [callOverloads5.js]
var Foo = (function () {
function Foo(x) {
// WScript.Echo("Constructor function has executed");
}
Foo.prototype.bar1 = function (a) {
};

View File

@ -63,6 +63,14 @@ class c8 {
}
var i8 = new c8();
var i8_c = c8;
class c9 {
constructor() {
/// This is some detached comment
// should emit this leading comment of } too
}
}
//// [commentsClass.js]
@ -123,11 +131,20 @@ var c8 = (function () {
/** constructor comment
*/
function c8() {
/** constructor comment2
*/
}
return c8;
})();
var i8 = new c8();
var i8_c = c8;
var c9 = (function () {
function c9() {
/// This is some detached comment
// should emit this leading comment of } too
}
return c9;
})();
//// [commentsClass.d.ts]
@ -178,3 +195,6 @@ declare class c8 {
}
declare var i8: c8;
declare var i8_c: typeof c8;
declare class c9 {
constructor();
}

View File

@ -130,3 +130,13 @@ var i8_c = c8;
>i8_c : typeof c8
>c8 : typeof c8
class c9 {
>c9 : c9
constructor() {
/// This is some detached comment
// should emit this leading comment of } too
}
}

View File

@ -65,3 +65,11 @@ class c8 {
}
var i8 = new c8();
var i8_c = c8;
class c9 {
constructor() {
/// This is some detached comment
// should emit this leading comment of } too
}
}