fix(47261): allow linkcode/linkplain tags in see tag (#47403)

This commit is contained in:
Oleksandr T 2022-02-16 03:20:51 +02:00 committed by GitHub
parent a0bab5de5c
commit b9a06e515f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 70 additions and 4 deletions

View File

@ -8148,12 +8148,14 @@ namespace ts {
&& nextTokenJSDoc() === SyntaxKind.AtToken
&& tokenIsIdentifierOrKeyword(nextTokenJSDoc())) {
const kind = scanner.getTokenValue();
if(kind === "link" || kind === "linkcode" || kind === "linkplain") {
return kind;
}
if (isJSDocLinkTag(kind)) return kind;
}
}
function isJSDocLinkTag(kind: string) {
return kind === "link" || kind === "linkcode" || kind === "linkplain";
}
function parseUnknownTag(start: number, tagName: Identifier, indent: number, indentText: string) {
return finishNode(factory.createJSDocUnknownTag(tagName, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start);
}
@ -8276,7 +8278,7 @@ namespace ts {
function parseSeeTag(start: number, tagName: Identifier, indent?: number, indentText?: string): JSDocSeeTag {
const isMarkdownOrJSDocLink = token() === SyntaxKind.OpenBracketToken
|| lookAhead(() => nextTokenJSDoc() === SyntaxKind.AtToken && tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenValue() === "link");
|| lookAhead(() => nextTokenJSDoc() === SyntaxKind.AtToken && tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && isJSDocLinkTag(scanner.getTokenValue()));
const nameExpression = isMarkdownOrJSDocLink ? undefined : parseJSDocNameReference();
const comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined;
return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start);

View File

@ -0,0 +1,23 @@
//// [seeTag4.js]
/**
* @typedef {any} A
*/
/**
* @see {@link A}
* @see {@linkcode A}
* @see {@linkplain A}
*/
let foo;
//// [seeTag4.js]
/**
* @typedef {any} A
*/
/**
* @see {@link A}
* @see {@linkcode A}
* @see {@linkplain A}
*/
var foo;

View File

@ -0,0 +1,13 @@
=== tests/cases/conformance/jsdoc/seeTag4.js ===
/**
* @typedef {any} A
*/
/**
* @see {@link A}
* @see {@linkcode A}
* @see {@linkplain A}
*/
let foo;
>foo : Symbol(foo, Decl(seeTag4.js, 9, 3))

View File

@ -0,0 +1,13 @@
=== tests/cases/conformance/jsdoc/seeTag4.js ===
/**
* @typedef {any} A
*/
/**
* @see {@link A}
* @see {@linkcode A}
* @see {@linkplain A}
*/
let foo;
>foo : any

View File

@ -0,0 +1,15 @@
// @checkJs: true
// @allowJs: true
// @outdir: out/
// @filename: seeTag4.js
/**
* @typedef {any} A
*/
/**
* @see {@link A}
* @see {@linkcode A}
* @see {@linkplain A}
*/
let foo;