Don't emit detached comment if removeComment is true

This commit is contained in:
Yui T 2015-08-20 09:47:45 -07:00
parent 5d15218cbe
commit 21ebc71325
5 changed files with 51 additions and 1 deletions

View file

@ -7045,7 +7045,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
function emitDetachedComments(node: TextRange) {
let leadingComments = getLeadingCommentRanges(currentSourceFile.text, node.pos);
let leadingComments = filterComments(getLeadingCommentRanges(currentSourceFile.text, node.pos), node.pos === 0);
if (leadingComments) {
let detachedComments: CommentRange[] = [];
let lastComment: CommentRange;

View file

@ -0,0 +1,15 @@
//// [doNotEmitdetachedCommentAtStartOfFunctionBody.ts]
function foo() {
/*
multi line
comment
*/
return 42;
}
//// [doNotEmitdetachedCommentAtStartOfFunctionBody.js]
function foo() {
return 42;
}

View file

@ -0,0 +1,12 @@
=== tests/cases/compiler/doNotEmitdetachedCommentAtStartOfFunctionBody.ts ===
function foo() {
>foo : Symbol(foo, Decl(doNotEmitdetachedCommentAtStartOfFunctionBody.ts, 0, 0))
/*
multi line
comment
*/
return 42;
}

View file

@ -0,0 +1,13 @@
=== tests/cases/compiler/doNotEmitdetachedCommentAtStartOfFunctionBody.ts ===
function foo() {
>foo : () => number
/*
multi line
comment
*/
return 42;
>42 : number
}

View file

@ -0,0 +1,10 @@
// @comments: false
function foo() {
/*
multi line
comment
*/
return 42;
}