Repository navigation
Ignore the synthetic this parameter when matching JSDoc params (Fixes #65524) - #65552
Open
刘亦达 (zhengdaodeguL) wants to merge 1 commit into
Open
刘亦达 (zhengdaodeguL) wants to merge 1 commit into
刘亦达 (zhengdaodeguL) wants to merge 1 commit into
Conversation
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.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #65524
A
@thistag inserts a syntheticthisparameter at index 0.findMatchingParameterandcheckUnmatchedJSDocParametersmatched@paramtags 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
thisparameter (either synthesized by@thisor declared explicitly in source) when aligning@paramtags positionally, in bothfindMatchingParameter(tsc/internal/parser/reparser.go) andcheckUnmatchedJSDocParameters(tsc/internal/checker/jsdoc.go, including theexcludedParametersindex for destructured parameters).Added regression test
tsc/testdata/tests/cases/compiler/jsdocThisTagWithDestructuredParameter.ts(the issue repro verbatim) with accepted baselines; no.errorsbaseline 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/jsdocpasses;go test ./internal/parser ./internal/checkerpasses;go vetandgofmt -lclean.