Skip to content

Ignore the synthetic this parameter when matching JSDoc params - #65534

Closed
Josué Barros (joshbarros) wants to merge 1 commit into
microsoft:mainfrom
joshbarros:fix/65524-jsdoc-this-destructured-param
Closed

Josué Barros (joshbarros) wants to merge 1 commit into
microsoft:mainfrom
joshbarros:fix/65524-jsdoc-this-destructured-param

Conversation

@joshbarros

Copy link
Copy Markdown

Fixes #65524

A @this tag inserts a synthetic this parameter at index 0. findMatchingParameter and checkUnmatchedJSDocParameters matched @param tags by their index in the original parameter list, so the shift left the first real parameter unmatched. A destructured parameter then got no type, which produced TS7031, and TS8024 was reported for the valid @param.

This skips the leading this parameter when computing the @param position. A @this tag is not described by a @param tag, so the two lists line up again. An explicitly declared this parameter is handled the same way.

The new compiler test uses the report's destructured-parameter case. On the unfixed compiler it produces TS8024 and TS7031 and changes the type baseline; with the fix there are no diagnostics and title is typed.

Validation:

  • go test ./tsc/internal/testrunner -run 'TestLocal/jsdocThisTagWithDestructuredParameter' -count=1: fails without the change, passes with it.
  • go test ./tsc/internal/testrunner -run 'TestLocal/jsdoc' -count=1: pass.
  • go test ./tsc/internal/parser ./tsc/internal/checker -count=1: pass.
  • go vet and the repo's gofmt: clean.

Drafted with assistance from an AI assistant. I reviewed the diff and ran the tests above.

A @this tag inserts a synthetic `this` parameter at index 0. findMatchingParameter and checkUnmatchedJSDocParameters matched @PARAM tags by their index in the original parameter list, so the shift left the first real parameter unmatched. A destructured parameter then got no type and TS8024 was reported.

Skip the leading `this` parameter when computing the @PARAM position. A @this tag is not described by a @PARAM tag, so the two lists line up again.

Adds the report's destructured-parameter case as a compiler test.
Copilot AI balanced review requested due to automatic review settings November 16, 2026 18:29
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Nov 16, 2026
@typescript-automation typescript-automation Bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Nov 16, 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

No active review issues block the JSDoc parameter-matching fix.

No open issues 🎉

What changed in this PR

Fixes #65524 by excluding the leading this parameter introduced by JSDoc @this from positional @param matching, restoring correct typing for destructured parameters.

Changes:

  • Adjusts parser matching and checker diagnostics to account for the leading this parameter.
  • Adds a regression test with symbol and type baselines confirming that the destructured title parameter is typed as string.
File Description
tsc/​testdata/​tests/​cases/​compiler/​jsdocThisTagWithDestructuredParameter.ts Adds the @this and destructured-parameter regression case.
tsc/​testdata/​baselines/​reference/​compiler/​jsdocThisTagWithDestructuredParameter.types Records correct parameter and return types.
tsc/​testdata/​baselines/​reference/​compiler/​jsdocThisTagWithDestructuredParameter.symbols Records expected symbol bindings.
tsc/​internal/​parser/​reparser.go Offsets positional matching when @this introduces a leading parameter.
tsc/​internal/​checker/​jsdoc.go Applies the same offset when checking unmatched JSDoc parameters.

Review effort: Balanced

@github-project-automation github-project-automation Bot moved this from Not started to Done in PR Backlog Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[7.0 regression] JSDoc @this breaks @param matching for destructured parameter (TS8024)

3 participants