Skip to content

Commit 643cf30

Browse files
committed
Use getJsDocFromText to get trailing comments
Also update a couple of missed spots in the previous undo commits
1 parent ff9ccc9 commit 643cf30

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

src/compiler/emitter.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8288,11 +8288,7 @@ const _super = (function (geti, seti) {
82888288
emitNewLineBeforeLeadingComments(currentLineMap, writer, node, leadingComments);
82898289

82908290
// Leading comments are emitted at /*leading comment1 */space/*leading comment*/space
8291-
// However, a leading mid-line comment of the end of file token is emitted with spaces before,
8292-
// as if it were a trailing comment of the previous token
8293-
const commentStartsInMidLine = leadingComments && leadingComments.length && leadingComments[0].pos - 1 > 0 && currentText.charCodeAt(leadingComments[0].pos - 1) !== 10;
8294-
const isEndOfFile = node.kind === SyntaxKind.EndOfFileToken && commentStartsInMidLine;
8295-
emitComments(currentText, currentLineMap, writer, leadingComments, /*trailingSeparator*/ !isEndOfFile, newLine, writeComment);
8291+
emitComments(currentText, currentLineMap, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment);
82968292
}
82978293

82988294
function emitTrailingComments(node: Node) {

src/compiler/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ namespace ts {
652652

653653

654654
function addJSDocComment<T extends Node>(node: T): T {
655-
const comments = getLeadingCommentRangesOfNode(node, sourceFile);
655+
const comments = getJsDocCommentsFromText(node, sourceFile.text);
656656
if (comments) {
657657
for (const comment of comments) {
658658
const jsDoc = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos);

tests/baselines/reference/errorSupression1.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ var Foo = (function () {
1818
var baz = Foo.b;
1919
// Foo.b won't bind.
2020
baz.concat("y");
21-
// So we don't want an error on 'concat'.
21+
// So we don't want an error on 'concat'.

0 commit comments

Comments
 (0)