Repository navigation
Fix inline JSDoc links in optional type positions - #64732
Max Barinov (mbarinov) wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The focused parser change is correct and covered by parser, hover, definition, and regression tests.
0 open findings
What changed in this PR
Fixes JSDoc inline links being misparsed as optional type annotations.
Changes:
- Excludes
link,linkcode, andlinkplainfrom optional type parsing. - Adds parser and language-service regression coverage.
- Preserves ordinary JSDoc type annotation behavior.
| File | Description |
|---|---|
tsc/internal/parser/jsdoc.go |
Moves inline-link detection into optional type parsing. |
tsc/internal/parser/parser_test.go |
Tests link forms and ordinary types. |
tsc/internal/fourslash/tests/jsdocInlineLinksInTypePosition_test.go |
Tests hover and definition behavior. |
tsc/testdata/baselines/reference/fourslash/quickInfo/jsdocInlineLinksInTypePosition.baseline |
Records expected hover output. |
tsc/testdata/baselines/reference/fourslash/goToDefinition/jsdocInlineLinksInTypePosition.baseline.jsonc |
Records expected definition targets. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
|
@microsoft-github-policy-service agree |
|
TypeScript Bot (@typescript-bot) test it |
|
Hey Jake Bailey (@jakebailey), the results of running the DT tests are ready. Everything looks the same! |
|
Jake Bailey (@jakebailey) Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Jake Bailey (@jakebailey) Here are the results of running the user tests with tsc comparing Everything looks good! |
|
Jake Bailey (@jakebailey) Here are the results of running the top 400 repos with tsc comparing Everything looks good! |
Fixes #62244.
An inline JSDoc link immediately after
@throwsor@returns, such as@throws {@link C}, is parsed as a type expression. This splits the documentation into extra tags and prevents the link from resolving in hover and go-to-definition.Move the existing inline-link lookahead from the name-first parameter path into
tryParseTypeExpression, so optional type positions consistently recognizelink,linkcode, andlinkplain. Remove the redundant parameter guard. Ordinary{Type}annotations keep their existing behavior.Parser tests cover all three link forms after
@throws,@returns, and name-first@param, plus ordinary type annotations. A fourslash test checks hover and definition targets. Both regression tests fail on unchanged main and pass with the fix; the two new baselines were inspected before acceptance.Validation passed:
npx hereby generate,build,test,test:all,lint,format, andcheck:format; the documented API and extension builds/tests; and module/workspace checks. The Go suite reported 2,149 skipped tests. Local parser benchmarks showed unchanged allocation counts and overlapping timing ranges.git diff --checkflags only trailing spaces produced by the baseline generator; source checks and repository formatting pass.AI disclosure: I used Codex to prepare the fix and tests. I have reviewed and understand the final patch, and I will handle review feedback myself.