Skip to content

Fix inline JSDoc links in optional type positions - #64732

Open
Max Barinov (mbarinov) wants to merge 4 commits into
microsoft:mainfrom
mbarinov:fix/jsdoc-inline-type-position-62244
Open

Max Barinov (mbarinov) wants to merge 4 commits into
microsoft:mainfrom
mbarinov:fix/jsdoc-inline-type-position-62244

Conversation

@mbarinov

Copy link
Copy Markdown

Fixes #62244.

An inline JSDoc link immediately after @throws or @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 recognize link, linkcode, and linkplain. 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, and check: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 --check flags 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.

Copilot AI balanced review requested due to automatic review settings October 11, 2026 13:22
@typescript-automation typescript-automation Bot added the For Backlog Bug PRs that fix a backlog bug label Oct 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 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, and linkplain from 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.

@mbarinov

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@jakebailey

Copy link
Copy Markdown
Member

TypeScript Bot (@typescript-bot) test it

@typescript-automation

typescript-automation Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
test top400 ✅ Started ✅ Results
user test this ✅ Started ✅ Results
run dt ✅ Started ✅ Results
perf test this faster ✅ Started 👀 Results

@typescript-automation

Copy link
Copy Markdown
Contributor

Hey Jake Bailey (@jakebailey), the results of running the DT tests are ready.

Everything looks the same!

You can check the log here.

@typescript-automation

Copy link
Copy Markdown
Contributor

Jake Bailey (@jakebailey)
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-Unions - native
Errors 41 41 ~ ~ ~ p=1.000 n=12
Symbols 115,276 115,276 ~ ~ ~ p=1.000 n=12
Types 79,613 79,613 ~ ~ ~ p=1.000 n=12
Memory Used 133,876k (± 0.06%) 133,853k (± 0.04%) ~ 133,761k 134,007k p=0.702 n=12
Memory Allocs 2,189,959 (± 0.00%) 2,189,977 (± 0.00%) ~ 2,189,840 2,190,371 p=0.830 n=12
Config Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Parse Time 0.040s (± 2.92%) 0.040s (± 3.78%) ~ 0.036s 0.044s p=0.762 n=12
Bind Time 0.012s (±11.67%) 0.014s (±14.03%) ~ 0.010s 0.019s p=0.147 n=12
Check Time 0.498s (± 0.64%) 0.492s (± 0.73%) -0.006s (- 1.12%) 0.485s 0.503s p=0.021 n=12
Emit Time 0.273s (± 1.30%) 0.269s (± 0.82%) -0.005s (- 1.65%) 0.262s 0.275s p=0.029 n=12
Total Time 0.830s (± 0.72%) 0.821s (± 0.39%) -0.008s (- 1.02%) 0.810s 0.829s p=0.025 n=12
angular-1 - native
Errors 3 3 ~ ~ ~ p=1.000 n=12
Symbols 845,303 (± 0.06%) 845,220 (± 0.07%) ~ 842,818 846,224 p=1.000 n=12
Types 248,125 (± 0.00%) 248,125 (± 0.00%) ~ 248,120 248,135 p=0.759 n=12
Memory Used 750,417k (± 0.02%) 750,399k (± 0.02%) ~ 750,060k 750,784k p=0.378 n=12
Memory Allocs 12,915,727 (± 0.03%) 12,918,912 (± 0.04%) ~ 12,910,178 12,937,884 p=0.410 n=12
Config Time 0.017s 0.017s ~ ~ ~ p=1.000 n=12
Parse Time 0.259s (± 2.43%) 0.256s (± 2.82%) ~ 0.232s 0.269s p=0.599 n=12
Bind Time 0.058s (± 1.08%) 0.067s (±18.28%) ~ 0.056s 0.117s p=0.895 n=12
Check Time 0s 0s ~ ~ ~ p=1.000 n=12
Emit Time 1.556s (± 0.62%) 1.568s (± 0.97%) ~ 1.544s 1.617s p=0.117 n=12
Total Time 1.903s (± 0.66%) 1.922s (± 1.20%) ~ 1.895s 2.003s p=0.326 n=12
mui-docs - native
Errors 11,405 11,405 ~ ~ ~ p=1.000 n=12
Symbols 4,359,614 4,359,614 ~ ~ ~ p=1.000 n=12
Types 1,376,379 1,376,379 ~ ~ ~ p=1.000 n=12
Memory Used 2,812,387k (± 0.06%) 2,812,379k (± 0.07%) ~ 2,808,440k 2,819,422k p=0.977 n=12
Memory Allocs 32,812,661 (± 0.05%) 32,801,883 (± 0.06%) ~ 32,767,908 32,853,687 p=0.291 n=12
Config Time 0.017s 0.017s ~ ~ ~ p=1.000 n=12
Parse Time 0.511s (± 1.71%) 0.488s (± 2.84%) 🟩-0.023s (- 4.52%) 0.453s 0.524s p=0.011 n=12
Bind Time 0.002s 0.002s ~ ~ ~ p=1.000 n=12
Check Time 8.637s (± 0.55%) 8.659s (± 0.33%) ~ 8.530s 8.721s p=0.514 n=12
Emit Time 0.455s (± 7.05%) 0.448s (± 4.63%) ~ 0.426s 0.519s p=0.324 n=12
Total Time 10.386s (± 0.62%) 10.380s (± 0.50%) ~ 10.195s 10.497s p=0.854 n=12
strada-build-src - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 1,390,229 1,390,229 ~ ~ ~ p=1.000 n=12
Types 441,498 441,498 ~ ~ ~ p=1.000 n=12
Memory Used 1,632,946k (± 0.85%) 1,624,990k (± 0.70%) ~ 1,602,015k 1,661,706k p=0.478 n=12
Memory Allocs 92,209,891 (± 0.08%) 91,955,722 (± 0.17%) -254,169 (- 0.28%) 91,667,917 92,290,303 p=0.017 n=12
Config Time 0.003s (±15.93%) 0.003s (±11.47%) ~ 0.002s 0.004s p=0.355 n=12
Parse Time 0.200s (± 3.73%) 0.193s (± 3.90%) ~ 0.173s 0.209s p=0.311 n=12
Bind Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Check Time 1.797s (± 0.27%) 1.800s (± 0.69%) ~ 1.776s 1.847s p=1.000 n=12
Emit Time 0.306s (± 3.88%) 0.298s (± 4.55%) ~ 0.258s 0.327s p=0.311 n=12
Total Time 23.452s (± 0.53%) 23.204s (± 0.84%) -0.248s (- 1.06%) 22.640s 23.554s p=0.045 n=12
strada-compiler - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 334,953 334,953 ~ ~ ~ p=1.000 n=12
Types 197,616 197,616 ~ ~ ~ p=1.000 n=12
Memory Used 297,312k (± 0.01%) 297,297k (± 0.03%) ~ 297,063k 297,479k p=0.932 n=12
Memory Allocs 4,621,106 (± 0.01%) 4,620,939 (± 0.01%) ~ 4,619,678 4,622,213 p=0.682 n=12
Config Time 0.001s 0.001s ~ ~ ~ p=1.000 n=12
Parse Time 0.113s (± 5.11%) 0.111s (± 4.56%) ~ 0.099s 0.125s p=0.660 n=12
Bind Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Check Time 1.043s (± 0.38%) 1.039s (± 0.71%) ~ 1.024s 1.058s p=0.468 n=12
Emit Time 0.146s (± 5.68%) 0.147s (± 9.10%) ~ 0.094s 0.175s p=0.831 n=12
Total Time 1.355s (± 0.91%) 1.351s (± 0.88%) ~ 1.321s 1.383s p=0.580 n=12
ts-pre-modules - native
Errors 87 87 ~ ~ ~ p=1.000 n=12
Symbols 303,834 303,834 ~ ~ ~ p=1.000 n=12
Types 181,663 181,663 ~ ~ ~ p=1.000 n=12
Memory Used 258,136k (± 0.02%) 258,140k (± 0.02%) ~ 258,022k 258,238k p=0.966 n=12
Memory Allocs 1,613,622 (± 0.02%) 1,613,789 (± 0.02%) ~ 1,613,217 1,615,061 p=0.630 n=12
Config Time 0.000s 0.000s (±217.90%) ~ 0.000s 0.001s p=1.000 n=12
Parse Time 0.098s (± 4.55%) 0.100s (± 3.97%) ~ 0.090s 0.113s p=0.338 n=12
Bind Time 0.039s (±11.61%) 0.038s (±13.50%) ~ 0.027s 0.053s p=0.619 n=12
Check Time 0.813s (± 0.92%) 0.816s (± 0.79%) ~ 0.800s 0.831s p=0.504 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 0.963s (± 0.58%) 0.968s (± 0.67%) ~ 0.945s 0.981s p=0.147 n=12
vscode - native
Errors 395 395 ~ ~ ~ p=1.000 n=12
Symbols 11,287,880 11,288,749 +869 (+ 0.01%) ~ ~ p=0.000 n=12
Types 3,740,417 3,740,641 +224 (+ 0.01%) ~ ~ p=0.000 n=12
Memory Used 6,524,010k (± 0.01%) 6,523,619k (± 0.01%) ~ 6,521,930k 6,526,897k p=0.291 n=12
Memory Allocs 55,470,816 (± 0.01%) 55,472,277 (± 0.02%) ~ 55,457,310 55,525,224 p=0.590 n=12
Config Time 0.075s (± 0.24%) 0.075s (± 0.48%) ~ 0.074s 0.076s p=0.590 n=12
Parse Time 1.872s (± 3.93%) 1.881s (± 2.92%) ~ 1.716s 2.001s p=0.875 n=12
Bind Time 0.549s (±18.57%) 0.536s (±17.32%) ~ 0.445s 0.910s p=0.522 n=12
Check Time 14.056s (± 1.02%) 14.133s (± 0.86%) ~ 13.733s 14.297s p=0.418 n=12
Emit Time 4.677s (± 9.08%) 4.591s (± 9.04%) ~ 4.146s 5.818s p=0.755 n=12
Total Time 21.313s (± 1.58%) 21.299s (± 1.56%) ~ 20.875s 22.382s p=0.856 n=12
webpack - native
Errors 584 584 ~ ~ ~ p=1.000 n=12
Symbols 1,310,990 1,310,990 ~ ~ ~ p=1.000 n=12
Types 619,725 619,725 ~ ~ ~ p=1.000 n=12
Memory Used 945,219k (± 0.01%) 945,238k (± 0.01%) ~ 944,966k 945,517k p=0.799 n=12
Memory Allocs 6,647,238 (± 0.03%) 6,645,139 (± 0.02%) ~ 6,642,762 6,649,048 p=0.078 n=12
Config Time 0.009s 0.009s ~ ~ ~ p=1.000 n=12
Parse Time 0.301s (± 3.37%) 0.292s (± 2.64%) ~ 0.268s 0.314s p=0.213 n=12
Bind Time 0.083s (±14.88%) 0.091s (±18.43%) ~ 0.064s 0.136s p=0.619 n=12
Check Time 2.073s (± 0.67%) 2.079s (± 1.07%) ~ 2.037s 2.138s p=0.681 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 2.503s (± 0.55%) 2.507s (± 0.62%) ~ 2.481s 2.566s p=0.966 n=12
xstate-main - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 1,061,928 1,061,928 ~ ~ ~ p=1.000 n=12
Types 389,645 389,645 ~ ~ ~ p=1.000 n=12
Memory Used 554,323k (± 0.02%) 554,249k (± 0.02%) ~ 554,071k 554,528k p=0.219 n=12
Memory Allocs 4,886,322 (± 0.10%) 4,884,023 (± 0.09%) ~ 4,874,838 4,898,610 p=0.319 n=12
Config Time 0.003s 0.003s ~ ~ ~ p=1.000 n=12
Parse Time 0.148s (± 4.01%) 0.149s (± 2.95%) ~ 0.140s 0.163s p=0.659 n=12
Bind Time 0.046s (±12.90%) 0.039s (±12.39%) ~ 0.033s 0.058s p=0.096 n=12
Check Time 1.129s (± 0.45%) 1.132s (± 0.56%) ~ 1.117s 1.149s p=0.385 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 1.336s (± 0.71%) 1.334s (± 0.81%) ~ 1.307s 1.367s p=0.681 n=12
System info unknown
Hosts
  • native
Scenarios
  • Compiler-Unions - native
  • angular-1 - native
  • mui-docs - native
  • strada-build-src - native
  • strada-compiler - native
  • ts-pre-modules - native
  • vscode - native
  • webpack - native
  • xstate-main - native
Benchmark Name Iterations
Current pr 12
Baseline baseline 12

Developer Information:

Download Benchmarks

@typescript-automation

Copy link
Copy Markdown
Contributor

Jake Bailey (@jakebailey) Here are the results of running the user tests with tsc comparing baseline and pr:

Everything looks good!

@typescript-automation

Copy link
Copy Markdown
Contributor

Jake Bailey (@jakebailey) Here are the results of running the top 400 repos with tsc comparing baseline and pr:

Everything looks good!

This branch has not been deployed

No deployments
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.

JSDoc tags not parsed when a type may be present

3 participants