Skip to content

Commit b9a06e5

Browse files
authored
fix(47261): allow linkcode/linkplain tags in see tag (microsoft#47403)
1 parent a0bab5d commit b9a06e5

File tree

5 files changed

+70
-4
lines changed

5 files changed

+70
-4
lines changed

src/compiler/parser.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -8148,12 +8148,14 @@ namespace ts {
81488148
&& nextTokenJSDoc() === SyntaxKind.AtToken
81498149
&& tokenIsIdentifierOrKeyword(nextTokenJSDoc())) {
81508150
const kind = scanner.getTokenValue();
8151-
if(kind === "link" || kind === "linkcode" || kind === "linkplain") {
8152-
return kind;
8153-
}
8151+
if (isJSDocLinkTag(kind)) return kind;
81548152
}
81558153
}
81568154

8155+
function isJSDocLinkTag(kind: string) {
8156+
return kind === "link" || kind === "linkcode" || kind === "linkplain";
8157+
}
8158+
81578159
function parseUnknownTag(start: number, tagName: Identifier, indent: number, indentText: string) {
81588160
return finishNode(factory.createJSDocUnknownTag(tagName, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start);
81598161
}
@@ -8276,7 +8278,7 @@ namespace ts {
82768278

82778279
function parseSeeTag(start: number, tagName: Identifier, indent?: number, indentText?: string): JSDocSeeTag {
82788280
const isMarkdownOrJSDocLink = token() === SyntaxKind.OpenBracketToken
8279-
|| lookAhead(() => nextTokenJSDoc() === SyntaxKind.AtToken && tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenValue() === "link");
8281+
|| lookAhead(() => nextTokenJSDoc() === SyntaxKind.AtToken && tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && isJSDocLinkTag(scanner.getTokenValue()));
82808282
const nameExpression = isMarkdownOrJSDocLink ? undefined : parseJSDocNameReference();
82818283
const comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined;
82828284
return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start);

tests/baselines/reference/seeTag4.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//// [seeTag4.js]
2+
/**
3+
* @typedef {any} A
4+
*/
5+
6+
/**
7+
* @see {@link A}
8+
* @see {@linkcode A}
9+
* @see {@linkplain A}
10+
*/
11+
let foo;
12+
13+
14+
//// [seeTag4.js]
15+
/**
16+
* @typedef {any} A
17+
*/
18+
/**
19+
* @see {@link A}
20+
* @see {@linkcode A}
21+
* @see {@linkplain A}
22+
*/
23+
var foo;
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
=== tests/cases/conformance/jsdoc/seeTag4.js ===
2+
/**
3+
* @typedef {any} A
4+
*/
5+
6+
/**
7+
* @see {@link A}
8+
* @see {@linkcode A}
9+
* @see {@linkplain A}
10+
*/
11+
let foo;
12+
>foo : Symbol(foo, Decl(seeTag4.js, 9, 3))
13+
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
=== tests/cases/conformance/jsdoc/seeTag4.js ===
2+
/**
3+
* @typedef {any} A
4+
*/
5+
6+
/**
7+
* @see {@link A}
8+
* @see {@linkcode A}
9+
* @see {@linkplain A}
10+
*/
11+
let foo;
12+
>foo : any
13+
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// @checkJs: true
2+
// @allowJs: true
3+
// @outdir: out/
4+
// @filename: seeTag4.js
5+
6+
/**
7+
* @typedef {any} A
8+
*/
9+
10+
/**
11+
* @see {@link A}
12+
* @see {@linkcode A}
13+
* @see {@linkplain A}
14+
*/
15+
let foo;

0 commit comments

Comments
 (0)