-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
base: main
Are you sure you want to change the base?
Conversation
7dac38a
to
5d7ead4
Compare
There was a problem hiding this 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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
closes #58599