Skip to content

Ignore the synthetic this parameter when matching JSDoc params (Fixes #65524) - #65552

Open
刘亦达 (zhengdaodeguL) wants to merge 1 commit into
microsoft:mainfrom
zhengdaodeguL:fix/jsdoc-this-param-match-65524
Open

刘亦达 (zhengdaodeguL) wants to merge 1 commit into
microsoft:mainfrom
zhengdaodeguL:fix/jsdoc-this-param-match-65524

Conversation

@zhengdaodeguL

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 a leading this parameter (either synthesized by @this or declared explicitly in source) when aligning @param tags positionally, in both findMatchingParameter (tsc/internal/parser/reparser.go) and checkUnmatchedJSDocParameters (tsc/internal/checker/jsdoc.go, including the excludedParameters index for destructured parameters).

Added regression test tsc/testdata/tests/cases/compiler/jsdocThisTagWithDestructuredParameter.ts (the issue repro verbatim) with accepted baselines; no .errors baseline means zero errors. Verified: the new test fails before the fix with exactly the two reported errors (TS8024, TS7031) and passes 9/9 subtests after; go test ./internal/testrunner -run TestLocal/jsdoc passes; go test ./internal/parser ./internal/checker passes; go vet and gofmt -l clean.

Fixes microsoft#65524

A @this tag inserts a synthetic this parameter at index 0, which shifted
positional @PARAM matching by one: the first real parameter was left
unmatched, so a destructured parameter got no type (TS7031) and its valid
@PARAM tag was reported as unmatched (TS8024).

Both findMatchingParameter (parser/reparser.go) and
checkUnmatchedJSDocParameters (checker/jsdoc.go) now skip a leading
parameter named this when computing @PARAM positions. This covers the
synthetic parameter from @this as well as an explicitly declared this
parameter. Adds the report's destructured-parameter case as a compiler
test.

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

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.

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

2 participants