fix(checker): mark getter/setter as deprecated when any declaration has @deprecated#63176
Open
TheAbMehta wants to merge 1 commit intomicrosoft:mainfrom
Open
fix(checker): mark getter/setter as deprecated when any declaration has @deprecated#63176TheAbMehta wants to merge 1 commit intomicrosoft:mainfrom
TheAbMehta wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Author
|
@microsoft-github-policy-service agree |
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.
Summary
Fixes #62965
@deprecatedJSDoc tag on a getter or setter no longer marks the property as deprecated in completions or suggestion diagnostics when only one accessor of the pair has the tag. This is a regression introduced in #41941.Problem
Getter/setter pairs share a single symbol with two declarations. PR #41941 changed the deprecation check to require all declarations to be deprecated (using
every()), which is correct for function overloads but incorrect for accessor pairs. If only the getter has@deprecated, the property should still appear deprecated when reading it — and vice versa for the setter.Three locations needed fixing:
src/compiler/checker.ts—isDeprecatedSymbol(): For symbols withSymbolFlags.Accessor, usesome()instead ofevery()to check declarations, matching the existing behavior for interface members.src/services/completions.ts—isDeprecated(): Same fix — usesome()for accessor symbols so completion items get the deprecated sort text.src/services/symbolDisplay.ts—getNormalizedSymbolModifiers(): The existing logic strips the deprecated modifier when the first declaration is deprecated but others aren't. For accessor symbols, re-add the deprecated modifier if any declaration has@deprecated.Tests
completionsWithDeprecatedGetterSetter.ts— verifies deprecatedkindModifiersandsortTextin completions for getter/setter pairs where only one accessor has@deprecatedjsdocDeprecated_suggestionGetterSetter.ts— verifies suggestion diagnostics (strikethrough) for the same scenariosAll existing
completionsWithDeprecatedTag*andjsdocDeprecated_suggestion*tests continue to pass.Disclosure
This PR was authored with the assistance of Claude (LLM) to help understand the codebase and structure the implementation and description.