diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 574c496d747..1821acd0a1f 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -8288,11 +8288,7 @@ const _super = (function (geti, seti) { emitNewLineBeforeLeadingComments(currentLineMap, writer, node, leadingComments); // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space - // However, a leading mid-line comment of the end of file token is emitted with spaces before, - // as if it were a trailing comment of the previous token - const commentStartsInMidLine = leadingComments && leadingComments.length && leadingComments[0].pos - 1 > 0 && currentText.charCodeAt(leadingComments[0].pos - 1) !== 10; - const isEndOfFile = node.kind === SyntaxKind.EndOfFileToken && commentStartsInMidLine; - emitComments(currentText, currentLineMap, writer, leadingComments, /*trailingSeparator*/ !isEndOfFile, newLine, writeComment); + emitComments(currentText, currentLineMap, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment); } function emitTrailingComments(node: Node) { diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 445af2243df..59fc1ef004b 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -652,7 +652,7 @@ namespace ts { function addJSDocComment(node: T): T { - const comments = getLeadingCommentRangesOfNode(node, sourceFile); + const comments = getJsDocCommentsFromText(node, sourceFile.text); if (comments) { for (const comment of comments) { const jsDoc = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); diff --git a/tests/baselines/reference/errorSupression1.js b/tests/baselines/reference/errorSupression1.js index 285aa525b5f..77545131ce3 100644 --- a/tests/baselines/reference/errorSupression1.js +++ b/tests/baselines/reference/errorSupression1.js @@ -18,4 +18,4 @@ var Foo = (function () { var baz = Foo.b; // Foo.b won't bind. baz.concat("y"); - // So we don't want an error on 'concat'. +// So we don't want an error on 'concat'.