Skip to content

fix(47261): TS error when JSDoc @see tag starts with an inline @linkcode tag #47403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8146,12 +8146,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);
}
Expand Down Expand Up @@ -8274,7 +8276,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);
Expand Down
23 changes: 23 additions & 0 deletions tests/baselines/reference/seeTag4.js
Original file line number Diff line number Diff line change
@@ -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;
13 changes: 13 additions & 0 deletions tests/baselines/reference/seeTag4.symbols
Original file line number Diff line number Diff line change
@@ -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))

13 changes: 13 additions & 0 deletions tests/baselines/reference/seeTag4.types
Original file line number Diff line number Diff line change
@@ -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

15 changes: 15 additions & 0 deletions tests/cases/conformance/jsdoc/seeTag4.ts
Original file line number Diff line number Diff line change
@@ -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;