fix: Deprecation error message reporting method type as deprecated instead...#63520
Closed
arnavnagzirkar wants to merge 2 commits into
Closed
fix: Deprecation error message reporting method type as deprecated instead...#63520arnavnagzirkar wants to merge 2 commits into
arnavnagzirkar wants to merge 2 commits into
Conversation
Member
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
Root Cause
In
src/compiler/checker.ts, the functionaddDeprecatedSuggestionWithSignaturewas missing a check for whendeprecatedEntityisundefinedbutlocationis anIdentifier. In that case, it fell through to usesignatureString(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,tryGetPropertyAccessOrIdentifierToStringreturnsundefinedbecause the base of the property access is aCallExpression(not an identifier or simple property access). As a result,name/deprecatedEntityisundefined. Without the identifier check, the code would fall through and usesignatureStringin the message.Change Made
src/compiler/checker.ts— Added anisIdentifier(location)branch inaddDeprecatedSuggestionWithSignature:When
deprecatedEntityisundefinedand the suggestion node is an identifier (e.g., the method nameoldMethod), we now useidText(location)(the identifier text) instead ofsignatureString(the type signature). This produces'oldMethod' is deprecatedinstead of'(): void' is deprecated.Issue
Fixes #62396
Issue URL: #62396
Changes
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.