diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 839107555cd..198adc4c37e 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -330,6 +330,8 @@ module ts { /** Emit Trailing comments of the node */ var emitTrailingComments = compilerOptions.removeComments ? (node: Node) => { } : emitTrailingDeclarationComments; + var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? (pos: number) => { } : emitLeadingCommentsOfLocalPosition; + var detachedCommentsInfo: { nodePos: number; detachedCommentEndPos: number }[]; /** Emit detached comments of the node */ var emitDetachedComments = compilerOptions.removeComments ? (node: TextRange) => { } : emitDetachedCommentsAtPosition; @@ -1390,12 +1392,14 @@ module ts { write(";"); emitTrailingComments(node.body); } - decreaseIndent(); writeLine(); if (node.body.kind === SyntaxKind.FunctionBlock) { + emitLeadingCommentsOfPosition((node.body).statements.end); + decreaseIndent(); emitToken(SyntaxKind.CloseBraceToken, (node.body).statements.end); } else { + decreaseIndent(); emitStart(node.body); write("}"); emitEnd(node.body); @@ -1648,8 +1652,11 @@ module ts { if (superCall) statements = statements.slice(1); emitLines(statements); } - decreaseIndent(); writeLine(); + if (ctor) { + emitLeadingCommentsOfPosition((ctor.body).statements.end); + } + decreaseIndent(); emitToken(SyntaxKind.CloseBraceToken, ctor ? (ctor.body).statements.end : node.members.end); scopeEmitEnd(); emitEnd(ctor || node); @@ -2077,23 +2084,34 @@ module ts { } } + function hasDetachedComments(pos: number) { + return detachedCommentsInfo !== undefined && detachedCommentsInfo[detachedCommentsInfo.length - 1].nodePos === pos; + } + + function getLeadingCommentsWithoutDetachedComments() { + // get the leading comments from detachedPos + var leadingComments = getLeadingComments(currentSourceFile.text, detachedCommentsInfo[detachedCommentsInfo.length - 1].detachedCommentEndPos); + if (detachedCommentsInfo.length - 1) { + detachedCommentsInfo.pop(); + } + else { + detachedCommentsInfo = undefined; + } + + return leadingComments; + } + function emitLeadingDeclarationComments(node: Node) { // Emit the leading comments only if the parent's pos doesnt match because parent should take care of emitting these comments if (node.parent.kind === SyntaxKind.SourceFile || node.pos !== node.parent.pos) { var leadingComments: Comment[]; - if (detachedCommentsInfo === undefined || detachedCommentsInfo[detachedCommentsInfo.length - 1].nodePos !== node.pos) { - // get the leading comments from the node - leadingComments = getLeadingCommentsOfNode(node, currentSourceFile); + if (hasDetachedComments(node.pos)) { + // get comments without detached comments + leadingComments = getLeadingCommentsWithoutDetachedComments(); } else { - // get the leading comments from detachedPos - leadingComments = getLeadingComments(currentSourceFile.text, detachedCommentsInfo[detachedCommentsInfo.length - 1].detachedCommentEndPos); - if (detachedCommentsInfo.length - 1) { - detachedCommentsInfo.pop(); - } - else { - detachedCommentsInfo = undefined; - } + // get the leading comments from the node + leadingComments = getLeadingCommentsOfNode(node, currentSourceFile); } emitNewLineBeforeLeadingComments(node, leadingComments, writer); // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space @@ -2110,6 +2128,21 @@ module ts { } } + function emitLeadingCommentsOfLocalPosition(pos: number) { + var leadingComments: Comment[]; + if (hasDetachedComments(pos)) { + // get comments without detached comments + leadingComments = getLeadingCommentsWithoutDetachedComments(); + } + else { + // get the leading comments from the node + leadingComments = getLeadingComments(currentSourceFile.text, pos); + } + emitNewLineBeforeLeadingComments({ pos: pos, end: pos }, leadingComments, writer); + // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space + emitComments(leadingComments, /*trailingSeparator*/ true, writer, writeComment); + } + function emitDetachedCommentsAtPosition(node: TextRange) { var leadingComments = getLeadingComments(currentSourceFile.text, node.pos); if (leadingComments) { diff --git a/tests/baselines/reference/callOverloads1.js b/tests/baselines/reference/callOverloads1.js index 4d595108ab2..dc76fcba98a 100644 --- a/tests/baselines/reference/callOverloads1.js +++ b/tests/baselines/reference/callOverloads1.js @@ -20,6 +20,7 @@ Foo(); //// [callOverloads1.js] var Foo = (function () { function Foo(x) { + // WScript.Echo("Constructor function has executed"); } Foo.prototype.bar1 = function () { }; diff --git a/tests/baselines/reference/callOverloads2.js b/tests/baselines/reference/callOverloads2.js index f152bde71aa..be42753bc3d 100644 --- a/tests/baselines/reference/callOverloads2.js +++ b/tests/baselines/reference/callOverloads2.js @@ -28,6 +28,7 @@ Foo(); //// [callOverloads2.js] var Foo = (function () { function Foo(x) { + // WScript.Echo("Constructor function has executed"); } Foo.prototype.bar1 = function () { }; diff --git a/tests/baselines/reference/callOverloads3.js b/tests/baselines/reference/callOverloads3.js index 0791be6530f..93176cc1edb 100644 --- a/tests/baselines/reference/callOverloads3.js +++ b/tests/baselines/reference/callOverloads3.js @@ -21,6 +21,7 @@ Foo("s"); //// [callOverloads3.js] var Foo = (function () { function Foo(x) { + // WScript.Echo("Constructor function has executed"); } Foo.prototype.bar1 = function () { }; diff --git a/tests/baselines/reference/callOverloads4.js b/tests/baselines/reference/callOverloads4.js index 19bed1db437..86ec2b91e7e 100644 --- a/tests/baselines/reference/callOverloads4.js +++ b/tests/baselines/reference/callOverloads4.js @@ -21,6 +21,7 @@ Foo("s"); //// [callOverloads4.js] var Foo = (function () { function Foo(x) { + // WScript.Echo("Constructor function has executed"); } Foo.prototype.bar1 = function () { }; diff --git a/tests/baselines/reference/callOverloads5.js b/tests/baselines/reference/callOverloads5.js index 4b93fee7a40..30cc65915ec 100644 --- a/tests/baselines/reference/callOverloads5.js +++ b/tests/baselines/reference/callOverloads5.js @@ -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) { }; diff --git a/tests/baselines/reference/classMemberInitializerWithLamdaScoping.js b/tests/baselines/reference/classMemberInitializerWithLamdaScoping.js index aabba3c1b2c..a431f6aceb8 100644 --- a/tests/baselines/reference/classMemberInitializerWithLamdaScoping.js +++ b/tests/baselines/reference/classMemberInitializerWithLamdaScoping.js @@ -52,6 +52,8 @@ var Test1 = (function () { this.field1 = field1; this.messageHandler = function () { console.log(field1); // But this should be error as the field1 will resolve to var field1 + // but since this code would be generated inside constructor, in generated js + // it would resolve to private field1 and thats not what user intended here. }; } Test1.staticMessageHandler = function () { diff --git a/tests/baselines/reference/classMemberInitializerWithLamdaScoping2.js b/tests/baselines/reference/classMemberInitializerWithLamdaScoping2.js index 81b6eb08e65..8509d60de7c 100644 --- a/tests/baselines/reference/classMemberInitializerWithLamdaScoping2.js +++ b/tests/baselines/reference/classMemberInitializerWithLamdaScoping2.js @@ -25,6 +25,8 @@ var Test1 = (function () { this.field1 = field1; this.messageHandler = function () { console.log(field1); // But this should be error as the field1 will resolve to var field1 + // but since this code would be generated inside constructor, in generated js + // it would resolve to private field1 and thats not what user intended here. }; } return Test1; diff --git a/tests/baselines/reference/classOrder1.js b/tests/baselines/reference/classOrder1.js index 6748a45444d..68bf1cd2a45 100644 --- a/tests/baselines/reference/classOrder1.js +++ b/tests/baselines/reference/classOrder1.js @@ -16,6 +16,7 @@ var A = (function () { function A() { } A.prototype.foo = function () { + /*WScript.Echo("Here!");*/ }; return A; })(); diff --git a/tests/baselines/reference/commentsClass.js b/tests/baselines/reference/commentsClass.js index f7f6025dc11..b42235e9afe 100644 --- a/tests/baselines/reference/commentsClass.js +++ b/tests/baselines/reference/commentsClass.js @@ -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(); +} diff --git a/tests/baselines/reference/commentsClass.types b/tests/baselines/reference/commentsClass.types index 5719059adfd..a4aca2ba15b 100644 --- a/tests/baselines/reference/commentsClass.types +++ b/tests/baselines/reference/commentsClass.types @@ -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 + } +} + diff --git a/tests/baselines/reference/commentsFunction.js b/tests/baselines/reference/commentsFunction.js index 69061278feb..0ffb2714108 100644 --- a/tests/baselines/reference/commentsFunction.js +++ b/tests/baselines/reference/commentsFunction.js @@ -41,7 +41,19 @@ lambdaFoo = (a, b) => a * b; // This is trailing comment /*leading comment*/(() => 0); //trailing comment function blah4(/*1*/a: string/*2*/,/*3*/b: string/*4*/) { -} +} + +function foo1() { + + // should emit this +} + +function foo2() { + /// This is some detached comment + + // should emit this leading comment of } too +} + //// [commentsFunction.js] /** This comment should appear for foo*/ @@ -79,6 +91,13 @@ lambdaFoo = function (a, b) { return a * b; }; // This is trailing comment /*leading comment*/ (function () { return 0; }); //trailing comment function blah4(/*1*/ a /*2*/, /*3*/ b /*4*/) { } +function foo1() { + // should emit this +} +function foo2() { + /// This is some detached comment + // should emit this leading comment of } too +} //// [commentsFunction.d.ts] @@ -98,3 +117,5 @@ declare function blah(a: string): void; declare function blah2(a: string): void; declare function blah3(a: string): void; declare function blah4(a: string, b: string): void; +declare function foo1(): void; +declare function foo2(): void; diff --git a/tests/baselines/reference/commentsFunction.types b/tests/baselines/reference/commentsFunction.types index 5a1667fad39..642a1c42665 100644 --- a/tests/baselines/reference/commentsFunction.types +++ b/tests/baselines/reference/commentsFunction.types @@ -110,3 +110,18 @@ function blah4(/*1*/a: string/*2*/,/*3*/b: string/*4*/) { >a : string >b : string } + +function foo1() { +>foo1 : () => void + + // should emit this +} + +function foo2() { +>foo2 : () => void + + /// This is some detached comment + + // should emit this leading comment of } too +} + diff --git a/tests/baselines/reference/genericCallWithGenericSignatureArguments.js b/tests/baselines/reference/genericCallWithGenericSignatureArguments.js index 9342691aa5a..17094dae69c 100644 --- a/tests/baselines/reference/genericCallWithGenericSignatureArguments.js +++ b/tests/baselines/reference/genericCallWithGenericSignatureArguments.js @@ -66,6 +66,8 @@ function other2(x) { var r7 = foo(function (a) { return a; }, function (b) { return b; }); // T => T var r7b = foo(function (a) { return a; }, function (b) { return b; }); // {} => {} var r8 = r7(null); + // BUG 835518 + //var r9 = r7(new Date()); } function foo2(a, b) { var r; diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgsAndNumericIndexer.js b/tests/baselines/reference/genericCallWithObjectTypeArgsAndNumericIndexer.js index 8375bf07dcd..aa2da602e25 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgsAndNumericIndexer.js +++ b/tests/baselines/reference/genericCallWithObjectTypeArgsAndNumericIndexer.js @@ -54,4 +54,6 @@ function other3(arg) { var b; var r2 = foo(b); var d = r2[1]; + // BUG 821629 + //var u: U = r2[1]; // ok } diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgsAndStringIndexer.js b/tests/baselines/reference/genericCallWithObjectTypeArgsAndStringIndexer.js index dbc1579ab4a..c810ce01fd4 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgsAndStringIndexer.js +++ b/tests/baselines/reference/genericCallWithObjectTypeArgsAndStringIndexer.js @@ -55,4 +55,6 @@ function other3(arg) { var b; var r2 = foo(b); var d = r2['hm']; // ok + // BUG 821629 + //var u: U = r2['hm']; // ok } diff --git a/tests/baselines/reference/logicalOrOperatorWithTypeParameters.js b/tests/baselines/reference/logicalOrOperatorWithTypeParameters.js index 042d72db50b..e0fca87efa8 100644 --- a/tests/baselines/reference/logicalOrOperatorWithTypeParameters.js +++ b/tests/baselines/reference/logicalOrOperatorWithTypeParameters.js @@ -37,6 +37,7 @@ function fn2(t, u, v) { var r4 = u || u; var r5 = u || v; var r6 = u || v; + //var r7: T = u || v; } function fn3(t, u) { var r1 = t || u; diff --git a/tests/baselines/reference/missingReturnStatement1.js b/tests/baselines/reference/missingReturnStatement1.js index 91cc673dfd0..665194cd5fe 100644 --- a/tests/baselines/reference/missingReturnStatement1.js +++ b/tests/baselines/reference/missingReturnStatement1.js @@ -11,6 +11,7 @@ var Foo = (function () { function Foo() { } Foo.prototype.foo = function () { + //return 4; }; return Foo; })(); diff --git a/tests/baselines/reference/out-flag.js b/tests/baselines/reference/out-flag.js index 8a84c5e48f7..755703a12fe 100644 --- a/tests/baselines/reference/out-flag.js +++ b/tests/baselines/reference/out-flag.js @@ -27,6 +27,7 @@ var MyClass = (function () { return 42; }; MyClass.prototype.SetCount = function (value) { + // }; return MyClass; })(); diff --git a/tests/baselines/reference/out-flag.js.map b/tests/baselines/reference/out-flag.js.map index 6240cc58208..9247af9d5d4 100644 --- a/tests/baselines/reference/out-flag.js.map +++ b/tests/baselines/reference/out-flag.js.map @@ -1,2 +1,2 @@ //// [out-flag.js.map] -{"version":3,"file":"out-flag.js","sourceRoot":"","sources":["out-flag.ts"],"names":["MyClass","MyClass.constructor","MyClass.Count","MyClass.SetCount"],"mappings":"AAAA,eAAe;AAGf,AADA,oBAAoB;IACd,OAAO;IAAbA,SAAMA,OAAOA;IAYbC,CAACA;IAVGD,uBAAuBA;IAChBA,uBAAKA,GAAZA;QAEIE,MAAMA,CAACA,EAAEA,CAACA;IACdA,CAACA;IAEMF,0BAAQA,GAAfA,UAAgBA,KAAaA;IAG7BG,CAACA;IACLH,cAACA;AAADA,CAACA,AAZD,IAYC"} \ No newline at end of file +{"version":3,"file":"out-flag.js","sourceRoot":"","sources":["out-flag.ts"],"names":["MyClass","MyClass.constructor","MyClass.Count","MyClass.SetCount"],"mappings":"AAAA,eAAe;AAGf,AADA,oBAAoB;IACd,OAAO;IAAbA,SAAMA,OAAOA;IAYbC,CAACA;IAVGD,uBAAuBA;IAChBA,uBAAKA,GAAZA;QAEIE,MAAMA,CAACA,EAAEA,CAACA;IACdA,CAACA;IAEMF,0BAAQA,GAAfA,UAAgBA,KAAaA;QAEzBG,EAAEA;IACNA,CAACA;IACLH,cAACA;AAADA,CAACA,AAZD,IAYC"} \ No newline at end of file diff --git a/tests/baselines/reference/out-flag.sourcemap.txt b/tests/baselines/reference/out-flag.sourcemap.txt index e778447c991..c0289140552 100644 --- a/tests/baselines/reference/out-flag.sourcemap.txt +++ b/tests/baselines/reference/out-flag.sourcemap.txt @@ -143,17 +143,25 @@ sourceFile:out-flag.ts 4 >Emitted(10, 44) Source(12, 21) + SourceIndex(0) name (MyClass) 5 >Emitted(10, 49) Source(12, 34) + SourceIndex(0) name (MyClass) --- +>>> // +1 >^^^^^^^^ +2 > ^^ +1 >) + > { + > +2 > // +1 >Emitted(11, 9) Source(14, 9) + SourceIndex(0) name (MyClass.SetCount) +2 >Emitted(11, 11) Source(14, 11) + SourceIndex(0) name (MyClass.SetCount) +--- >>> }; 1 >^^^^ 2 > ^ 3 > ^^^^^^^^^^^^^^^-> -1 >) - > { - > // +1 > > 2 > } -1 >Emitted(11, 5) Source(15, 5) + SourceIndex(0) name (MyClass.SetCount) -2 >Emitted(11, 6) Source(15, 6) + SourceIndex(0) name (MyClass.SetCount) +1 >Emitted(12, 5) Source(15, 5) + SourceIndex(0) name (MyClass.SetCount) +2 >Emitted(12, 6) Source(15, 6) + SourceIndex(0) name (MyClass.SetCount) --- >>> return MyClass; 1->^^^^ @@ -161,8 +169,8 @@ sourceFile:out-flag.ts 1-> > 2 > } -1->Emitted(12, 5) Source(16, 1) + SourceIndex(0) name (MyClass) -2 >Emitted(12, 19) Source(16, 2) + SourceIndex(0) name (MyClass) +1->Emitted(13, 5) Source(16, 1) + SourceIndex(0) name (MyClass) +2 >Emitted(13, 19) Source(16, 2) + SourceIndex(0) name (MyClass) --- >>>})(); 1 > @@ -186,9 +194,9 @@ sourceFile:out-flag.ts > // > } > } -1 >Emitted(13, 1) Source(16, 1) + SourceIndex(0) name (MyClass) -2 >Emitted(13, 2) Source(16, 2) + SourceIndex(0) name (MyClass) -3 >Emitted(13, 2) Source(4, 1) + SourceIndex(0) -4 >Emitted(13, 6) Source(16, 2) + SourceIndex(0) +1 >Emitted(14, 1) Source(16, 1) + SourceIndex(0) name (MyClass) +2 >Emitted(14, 2) Source(16, 2) + SourceIndex(0) name (MyClass) +3 >Emitted(14, 2) Source(4, 1) + SourceIndex(0) +4 >Emitted(14, 6) Source(16, 2) + SourceIndex(0) --- >>>//# sourceMappingURL=out-flag.js.map \ No newline at end of file diff --git a/tests/baselines/reference/properties.js b/tests/baselines/reference/properties.js index c57d1c22ffa..67bfc0d9903 100644 --- a/tests/baselines/reference/properties.js +++ b/tests/baselines/reference/properties.js @@ -22,6 +22,7 @@ var MyClass = (function () { return 42; }, set: function (value) { + // }, enumerable: true, configurable: true diff --git a/tests/baselines/reference/properties.js.map b/tests/baselines/reference/properties.js.map index 3b30578b09f..d47694825ec 100644 --- a/tests/baselines/reference/properties.js.map +++ b/tests/baselines/reference/properties.js.map @@ -1,2 +1,2 @@ //// [properties.js.map] -{"version":3,"file":"properties.js","sourceRoot":"","sources":["properties.ts"],"names":["MyClass","MyClass.constructor","MyClass.Count"],"mappings":"AACA,IAAM,OAAO;IAAbA,SAAMA,OAAOA;IAWbC,CAACA;IATGD,sBAAWA,0BAAKA;aAAhBA;YAEIE,MAAMA,CAACA,EAAEA,CAACA;QACdA,CAACA;aAEDF,UAAiBA,KAAaA;QAG9BE,CAACA;;;OALAF;IAMLA,cAACA;AAADA,CAACA,AAXD,IAWC"} \ No newline at end of file +{"version":3,"file":"properties.js","sourceRoot":"","sources":["properties.ts"],"names":["MyClass","MyClass.constructor","MyClass.Count"],"mappings":"AACA,IAAM,OAAO;IAAbA,SAAMA,OAAOA;IAWbC,CAACA;IATGD,sBAAWA,0BAAKA;aAAhBA;YAEIE,MAAMA,CAACA,EAAEA,CAACA;QACdA,CAACA;aAEDF,UAAiBA,KAAaA;YAE1BE,EAAEA;QACNA,CAACA;;;OALAF;IAMLA,cAACA;AAADA,CAACA,AAXD,IAWC"} \ No newline at end of file diff --git a/tests/baselines/reference/properties.sourcemap.txt b/tests/baselines/reference/properties.sourcemap.txt index 2094301b4c0..7ef028e33c0 100644 --- a/tests/baselines/reference/properties.sourcemap.txt +++ b/tests/baselines/reference/properties.sourcemap.txt @@ -111,17 +111,25 @@ sourceFile:properties.ts 2 >Emitted(8, 24) Source(9, 22) + SourceIndex(0) name (MyClass) 3 >Emitted(8, 29) Source(9, 35) + SourceIndex(0) name (MyClass) --- +>>> // +1 >^^^^^^^^^^^^ +2 > ^^ +1 >) + > { + > +2 > // +1 >Emitted(9, 13) Source(11, 9) + SourceIndex(0) name (MyClass.Count) +2 >Emitted(9, 15) Source(11, 11) + SourceIndex(0) name (MyClass.Count) +--- >>> }, 1 >^^^^^^^^ 2 > ^ 3 > ^^^^^^^^^^^^^^^^^-> -1 >) - > { - > // +1 > > 2 > } -1 >Emitted(9, 9) Source(12, 5) + SourceIndex(0) name (MyClass.Count) -2 >Emitted(9, 10) Source(12, 6) + SourceIndex(0) name (MyClass.Count) +1 >Emitted(10, 9) Source(12, 5) + SourceIndex(0) name (MyClass.Count) +2 >Emitted(10, 10) Source(12, 6) + SourceIndex(0) name (MyClass.Count) --- >>> enumerable: true, >>> configurable: true @@ -129,7 +137,7 @@ sourceFile:properties.ts 1->^^^^^^^ 2 > ^^^^^^^^^^^^^-> 1-> -1->Emitted(12, 8) Source(7, 6) + SourceIndex(0) name (MyClass) +1->Emitted(13, 8) Source(7, 6) + SourceIndex(0) name (MyClass) --- >>> return MyClass; 1->^^^^ @@ -142,8 +150,8 @@ sourceFile:properties.ts > } > 2 > } -1->Emitted(13, 5) Source(13, 1) + SourceIndex(0) name (MyClass) -2 >Emitted(13, 19) Source(13, 2) + SourceIndex(0) name (MyClass) +1->Emitted(14, 5) Source(13, 1) + SourceIndex(0) name (MyClass) +2 >Emitted(14, 19) Source(13, 2) + SourceIndex(0) name (MyClass) --- >>>})(); 1 > @@ -166,9 +174,9 @@ sourceFile:properties.ts > // > } > } -1 >Emitted(14, 1) Source(13, 1) + SourceIndex(0) name (MyClass) -2 >Emitted(14, 2) Source(13, 2) + SourceIndex(0) name (MyClass) -3 >Emitted(14, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(14, 6) Source(13, 2) + SourceIndex(0) +1 >Emitted(15, 1) Source(13, 1) + SourceIndex(0) name (MyClass) +2 >Emitted(15, 2) Source(13, 2) + SourceIndex(0) name (MyClass) +3 >Emitted(15, 2) Source(2, 1) + SourceIndex(0) +4 >Emitted(15, 6) Source(13, 2) + SourceIndex(0) --- >>>//# sourceMappingURL=properties.js.map \ No newline at end of file diff --git a/tests/cases/compiler/commentsClass.ts b/tests/cases/compiler/commentsClass.ts index 6bc5103ad44..e9a8f3cee1d 100644 --- a/tests/cases/compiler/commentsClass.ts +++ b/tests/cases/compiler/commentsClass.ts @@ -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 + } +} diff --git a/tests/cases/compiler/commentsFunction.ts b/tests/cases/compiler/commentsFunction.ts index 06d3c1bbf98..b71da4ae085 100644 --- a/tests/cases/compiler/commentsFunction.ts +++ b/tests/cases/compiler/commentsFunction.ts @@ -43,4 +43,15 @@ lambdaFoo = (a, b) => a * b; // This is trailing comment /*leading comment*/(() => 0); //trailing comment function blah4(/*1*/a: string/*2*/,/*3*/b: string/*4*/) { -} \ No newline at end of file +} + +function foo1() { + + // should emit this +} + +function foo2() { + /// This is some detached comment + + // should emit this leading comment of } too +}