Skip to content

fix: Deprecation error message reporting method type as deprecated instead...#63520

Closed
arnavnagzirkar wants to merge 2 commits into
microsoft:mainfrom
arnavnagzirkar:fix-62396
Closed

fix: Deprecation error message reporting method type as deprecated instead...#63520
arnavnagzirkar wants to merge 2 commits into
microsoft:mainfrom
arnavnagzirkar:fix-62396

Conversation

@arnavnagzirkar
Copy link
Copy Markdown

Summary

Root Cause

In src/compiler/checker.ts, the function addDeprecatedSuggestionWithSignature was missing a check for when deprecatedEntity is undefined but location is an Identifier. In that case, it fell through to use signatureString (the full function type like (): ZodObject<...>) as the deprecated entity name in the diagnostic message.

This happens when calling a deprecated method on the result of a chained call (e.g., createBuilder().configure("x").oldMethod()). In this pattern, tryGetPropertyAccessOrIdentifierToString returns undefined because the base of the property access is a CallExpression (not an identifier or simple property access). As a result, name/deprecatedEntity is undefined. Without the identifier check, the code would fall through and use signatureString in the message.

Change Made

src/compiler/checker.ts — Added an isIdentifier(location) branch in addDeprecatedSuggestionWithSignature:

// Before:
const diagnostic = deprecatedEntity
    ? createDiagnosticForNode(location, Diagnostics.The_signature_0_of_1_is_deprecated, signatureString, deprecatedEntity)
    : createDiagnosticForNode(location, Diagnostics._0_is_deprecated, signatureString);

// After:
const diagnostic = deprecatedEntity
    ? createDiagnosticForNode(location, Diagnostics.The_signature_0_of_1_is_deprecated, signatureString, deprecatedEntity)
    : isIdentifier(location)
    ? createDiagnosticForNode(location, Diagnostics._0_is_deprecated, idText(location))
    : createDiagnosticForNode(location, Diagnostics._0_is_deprecated, signatureString);

When deprecatedEntity is undefined and the suggestion node is an identifier (e.g., the method name oldMethod), we now use idText(location) (the identifier text) instead of signatureString (the type signature). This produces 'oldMethod' is deprecated instead of '(): void' is deprecated.

Issue

Fixes #62396

Issue URL: #62396

Changes

src/compiler/checker.ts                            |  2 +
 .../deprecatedMethodOnChainedCall.errors.txt       | 22 +++++++++++
 .../deprecatedMethodOnChainedCall.symbols          | 32 +++++++++++++++
 .../reference/deprecatedMethodOnChainedCall.types  | 45 ++++++++++++++++++++++
 .../compiler/deprecatedMethodOnChainedCall.ts      | 17 ++++++++
 5 files changed, 118 insertions(+)

Testing

  • Agent ran relevant tests during development

  • Linting checks passed

  • Changes are minimal and focused on the issue

AI Assistance Disclosure

This PR was authored with the assistance of AI coding tools (GitHub Copilot). I have read and understand the change and will respond to review feedback myself.

Copilot AI review requested due to automatic review settings June 1, 2026 03:58
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Jun 1, 2026
@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Jun 1, 2026
@RyanCavanaugh
Copy link
Copy Markdown
Member

#63521 (comment)

@github-project-automation github-project-automation Bot moved this from Not started to Done in PR Backlog Jun 1, 2026
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: Done

Development

Successfully merging this pull request may close these issues.

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

3 participants