Skip to content

Conversation

hanseul37
Copy link

@hanseul37 hanseul37 commented Sep 5, 2025

Fix deprecation message to show method name instead of type (#62396)

Changes

  • Corrected the deprecation diagnostic message to display the actual method name instead of the method type.
  • Modified checkDeprecatedSignature and addDeprecatedSuggestionWithSignature functions to extract and show the invoked method name.

Summary of Changes

  1. In checkDeprecatedSignature:

    • Extract the invoked expression's name using tryGetPropertyAccessOrIdentifierToString.
    • If the name is missing and the expression is a PropertyAccessExpression, retrieve the name from propAccess.name.getText().
    • Fallback to <unknown> only if no name can be determined.
  2. In addDeprecatedSuggestionWithSignature:

    • Use the extracted method name for deprecated diagnostics when deprecatedEntity is falsy.
    • Retains correct behavior for both signature-level and declaration-level deprecation messages.

Problem Solved

  • Before: '(): ZodObject<{ compilerOptions: ZodAny; }, $loose>' is deprecated
  • After: 'passthrough()' is deprecated
  • The deprecation message now correctly shows the invoked method name instead of the type.

Related Issue

@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Sep 5, 2025
@hanseul37 hanseul37 changed the title Fix(deprecation): report method name instead of type for deprecated methods (#62396) Fix(deprecation): report method name instead of type for deprecated methods #62396 Sep 5, 2025
@hanseul37 hanseul37 changed the title Fix(deprecation): report method name instead of type for deprecated methods #62396 Fix(deprecation): report method name instead of type for deprecated methods Sep 5, 2025
@hanseul37
Copy link
Author

@microsoft-github-policy-service agree

@hanseul37 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Sep 8, 2025
Copy link
Member

@jakebailey jakebailey left a comment

Choose a reason for hiding this comment

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

This needs a test, but is probably wrong as it is casting nodes around to any to extract text. The fix should probably in the caller of addDeprecatedSuggestionWithSignature as that func is just a helper that automates adding a diagnostic.

@github-project-automation github-project-automation bot moved this from Not started to Waiting on author in PR Backlog Sep 8, 2025
@hanseul37 hanseul37 requested a review from jakebailey September 8, 2025 17:35
Copy link
Member

@RyanCavanaugh RyanCavanaugh left a comment

Choose a reason for hiding this comment

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

Please address the prior comment from Jake

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: Waiting on author
Development

Successfully merging this pull request may close these issues.

Deprecation error message reporting method type as deprecated instead of method name
4 participants