@@ -1413,6 +1413,7 @@ namespace Parser {
1413
1413
let IdentifierConstructor: new (kind: SyntaxKind.Identifier, pos: number, end: number) => Identifier;
1414
1414
let PrivateIdentifierConstructor: new (kind: SyntaxKind.PrivateIdentifier, pos: number, end: number) => PrivateIdentifier;
1415
1415
let SourceFileConstructor: new (kind: SyntaxKind.SourceFile, pos: number, end: number) => SourceFile;
1416
+ let isInTsserver = true;
1416
1417
1417
1418
function countNode(node: Node) {
1418
1419
nodeCount++;
@@ -1659,6 +1660,7 @@ namespace Parser {
1659
1660
IdentifierConstructor = objectAllocator.getIdentifierConstructor();
1660
1661
PrivateIdentifierConstructor = objectAllocator.getPrivateIdentifierConstructor();
1661
1662
SourceFileConstructor = objectAllocator.getSourceFileConstructor();
1663
+ isInTsserver = !!(new NodeConstructor(0, 0, 0).constructor);
1662
1664
1663
1665
fileName = normalizePath(_fileName);
1664
1666
sourceText = _sourceText;
@@ -1759,13 +1761,20 @@ namespace Parser {
1759
1761
}
1760
1762
1761
1763
function withJSDoc<T extends HasJSDoc>(node: T, hasJSDoc: boolean): T {
1762
- return hasJSDoc && (node.flags & NodeFlags.JavaScriptFile) ? addJSDocComment(node) : node;
1764
+ return hasJSDoc ? addJSDocComment(node) : node;
1765
+ }
1766
+
1767
+ function shouldCheckJSDoc<T extends HasJSDoc>(node: T, comment: ts.CommentRange) {
1768
+ if (isInTsserver) return true;
1769
+ if (node.flags & NodeFlags.JavaScriptFile) return true;
1770
+ const i = sourceText.indexOf("@link", comment.pos)
1771
+ if (comment.pos < i && i < comment.end) return true;
1763
1772
}
1764
1773
1765
1774
let hasDeprecatedTag = false;
1766
1775
function addJSDocComment<T extends HasJSDoc>(node: T): T {
1767
1776
Debug.assert(!node.jsDoc); // Should only be called once per node
1768
- const jsDoc = mapDefined(getJSDocCommentRanges(node, sourceText), comment => JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos));
1777
+ const jsDoc = mapDefined(getJSDocCommentRanges(node, sourceText), comment => shouldCheckJSDoc(node, comment) && JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos));
1769
1778
if (jsDoc.length) node.jsDoc = jsDoc;
1770
1779
if (hasDeprecatedTag) {
1771
1780
hasDeprecatedTag = false;
0 commit comments