@@ -1413,7 +1413,6 @@ 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;
1417
1416
1418
1417
function countNode(node: Node) {
1419
1418
nodeCount++;
@@ -1660,10 +1659,10 @@ namespace Parser {
1660
1659
IdentifierConstructor = objectAllocator.getIdentifierConstructor();
1661
1660
PrivateIdentifierConstructor = objectAllocator.getPrivateIdentifierConstructor();
1662
1661
SourceFileConstructor = objectAllocator.getSourceFileConstructor();
1663
- isInTsserver = (new NodeConstructor(0, 0, 0).constructor.name !== "Node");
1664
1662
1665
1663
fileName = normalizePath(_fileName);
1666
1664
sourceText = _sourceText;
1665
+
1667
1666
languageVersion = _languageVersion;
1668
1667
syntaxCursor = _syntaxCursor;
1669
1668
scriptKind = _scriptKind;
@@ -1764,19 +1763,17 @@ namespace Parser {
1764
1763
return hasJSDoc ? addJSDocComment(node) : node;
1765
1764
}
1766
1765
1767
- function shouldCheckJSDoc<T extends HasJSDoc>(node: T, comment: ts.CommentRange) {
1768
- if (isInTsserver) return true;
1766
+ const seeLink = /@(?:see|link)/;
1767
+ function shouldParseJSDoc<T extends HasJSDoc>(node: T, comment: ts.CommentRange) {
1768
+ if (!(globalThis as any).isTSC) return true;
1769
1769
if (node.flags & NodeFlags.JavaScriptFile) return true;
1770
- const link = sourceText.indexOf("@link", comment.pos);
1771
- const see = sourceText.indexOf("@see", comment.pos);
1772
- if (comment.pos < link && link < comment.end) return true;
1773
- if (comment.pos < see && see < comment.end) return true;
1770
+ if (seeLink.test(sourceText.slice(comment.pos, comment.end))) return true;
1774
1771
}
1775
1772
1776
1773
let hasDeprecatedTag = false;
1777
1774
function addJSDocComment<T extends HasJSDoc>(node: T): T {
1778
1775
Debug.assert(!node.jsDoc); // Should only be called once per node
1779
- const jsDoc = mapDefined(getJSDocCommentRanges(node, sourceText), comment => shouldCheckJSDoc (node, comment) && JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos));
1776
+ const jsDoc = mapDefined(getJSDocCommentRanges(node, sourceText), comment => shouldParseJSDoc (node, comment) && JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos));
1780
1777
if (jsDoc.length) node.jsDoc = jsDoc;
1781
1778
if (hasDeprecatedTag) {
1782
1779
hasDeprecatedTag = false;
0 commit comments