Skip to content

Improve @throws {@link CustomError} handling #61722

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Andarist
Copy link
Contributor

closes #58599

@Copilot Copilot AI review requested due to automatic review settings May 18, 2025 09:05
@Andarist Andarist force-pushed the fix/jsdoc-links-in-tags branch from 7dac38a to 5d7ead4 Compare May 18, 2025 09:05
@github-project-automation github-project-automation bot moved this to Not started in PR Backlog May 18, 2025
@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label May 18, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR improves the handling of the JSDoc @throws tag when a markdown or JSDoc link is used by centralizing the link-check logic and updating type expression parsing accordingly.

  • Added a new test file to validate quick info baseline for @throws links.
  • Refactored parser.ts to extract the markdown/JSDoc link check into the isMarkdownOrJSDocLink function.
  • Updated both parseSeeTag and parseThrowsTag to conditionally bypass name expression and type expression parsing when a link is detected.

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
tests/cases/fourslash/jsdocLink7.ts Adds a test file to verify proper baseline quick info handling.
src/compiler/parser.ts Refactors inline link detection logic into the isMarkdownOrJSDocLink function and updates tag parsing accordingly.
Files not reviewed (1)
  • tests/baselines/reference/jsdocLink7.baseline: Language not supported

const isMarkdownOrJSDocLink = token() === SyntaxKind.OpenBracketToken
|| lookAhead(() => nextTokenJSDoc() === SyntaxKind.AtToken && tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && isJSDocLinkTag(scanner.getTokenValue()));
const nameExpression = isMarkdownOrJSDocLink ? undefined : parseJSDocNameReference();
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);
}

function parseThrowsTag(start: number, tagName: Identifier, indent: number, indentText: string): JSDocThrowsTag {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LukeAbby suggested @returns and @yields could use the same treatment. @yields isn't a specialized tag in TS today so I skipped that and I'm slightly on the fence when it comes to @returns. cc @sandersn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Status: Not started
Development

Successfully merging this pull request may close these issues.

Syntax highlighting can not resolve @throws of tsdoc
2 participants