Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2626,6 +2626,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
function addDeprecatedSuggestionWithSignature(location: Node, declaration: Node, deprecatedEntity: string | undefined, signatureString: string) {
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);
return addDeprecatedSuggestionWorker(declaration, diagnostic);
}
Expand Down
22 changes: 22 additions & 0 deletions tests/baselines/reference/deprecatedMethodOnChainedCall.errors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
deprecatedMethodOnChainedCall.ts(14,32): suggestion TS6385: 'oldMethod' is deprecated.


==== deprecatedMethodOnChainedCall.ts (1 errors) ====
// Regression test for https://github.com/microsoft/TypeScript/issues/62396
// Deprecation message should show the method name, not the type signature

interface Builder {
configure(value: string): Builder;
/** @deprecated use {@link Builder} instead */
oldMethod(): void;
}

declare function createBuilder(): Builder;

// When calling a deprecated method on the result of another call (chained call),
// the deprecation message should show the method name, not the type signature.
createBuilder().configure("x").oldMethod();
~~~~~~~~~
!!! suggestion TS6385: 'oldMethod' is deprecated.
!!! related TS2798 deprecatedMethodOnChainedCall.ts:6:9: The declaration was marked as deprecated here.

32 changes: 32 additions & 0 deletions tests/baselines/reference/deprecatedMethodOnChainedCall.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//// [tests/cases/compiler/deprecatedMethodOnChainedCall.ts] ////

=== deprecatedMethodOnChainedCall.ts ===
// Regression test for https://github.com/microsoft/TypeScript/issues/62396
// Deprecation message should show the method name, not the type signature

interface Builder {
>Builder : Symbol(Builder, Decl(deprecatedMethodOnChainedCall.ts, 0, 0))

configure(value: string): Builder;
>configure : Symbol(Builder.configure, Decl(deprecatedMethodOnChainedCall.ts, 3, 19))
>value : Symbol(value, Decl(deprecatedMethodOnChainedCall.ts, 4, 14))
>Builder : Symbol(Builder, Decl(deprecatedMethodOnChainedCall.ts, 0, 0))

/** @deprecated use {@link Builder} instead */
oldMethod(): void;
>oldMethod : Symbol(Builder.oldMethod, Decl(deprecatedMethodOnChainedCall.ts, 4, 38))
}

declare function createBuilder(): Builder;
>createBuilder : Symbol(createBuilder, Decl(deprecatedMethodOnChainedCall.ts, 7, 1))
>Builder : Symbol(Builder, Decl(deprecatedMethodOnChainedCall.ts, 0, 0))

// When calling a deprecated method on the result of another call (chained call),
// the deprecation message should show the method name, not the type signature.
createBuilder().configure("x").oldMethod();
>createBuilder().configure("x").oldMethod : Symbol(Builder.oldMethod, Decl(deprecatedMethodOnChainedCall.ts, 4, 38))
>createBuilder().configure : Symbol(Builder.configure, Decl(deprecatedMethodOnChainedCall.ts, 3, 19))
>createBuilder : Symbol(createBuilder, Decl(deprecatedMethodOnChainedCall.ts, 7, 1))
>configure : Symbol(Builder.configure, Decl(deprecatedMethodOnChainedCall.ts, 3, 19))
>oldMethod : Symbol(Builder.oldMethod, Decl(deprecatedMethodOnChainedCall.ts, 4, 38))

45 changes: 45 additions & 0 deletions tests/baselines/reference/deprecatedMethodOnChainedCall.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//// [tests/cases/compiler/deprecatedMethodOnChainedCall.ts] ////

=== deprecatedMethodOnChainedCall.ts ===
// Regression test for https://github.com/microsoft/TypeScript/issues/62396
// Deprecation message should show the method name, not the type signature

interface Builder {
configure(value: string): Builder;
>configure : (value: string) => Builder
> : ^ ^^ ^^^^^
>value : string
> : ^^^^^^

/** @deprecated use {@link Builder} instead */
oldMethod(): void;
>oldMethod : () => void
> : ^^^^^^
}

declare function createBuilder(): Builder;
>createBuilder : () => Builder
> : ^^^^^^

// When calling a deprecated method on the result of another call (chained call),
// the deprecation message should show the method name, not the type signature.
createBuilder().configure("x").oldMethod();
>createBuilder().configure("x").oldMethod() : void
> : ^^^^
>createBuilder().configure("x").oldMethod : () => void
> : ^^^^^^
>createBuilder().configure("x") : Builder
> : ^^^^^^^
>createBuilder().configure : (value: string) => Builder
> : ^ ^^ ^^^^^
>createBuilder() : Builder
> : ^^^^^^^
>createBuilder : () => Builder
> : ^^^^^^
>configure : (value: string) => Builder
> : ^ ^^ ^^^^^
>"x" : "x"
> : ^^^
>oldMethod : () => void
> : ^^^^^^

17 changes: 17 additions & 0 deletions tests/cases/compiler/deprecatedMethodOnChainedCall.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// @noEmit: true
// @captureSuggestions: true

// Regression test for https://github.com/microsoft/TypeScript/issues/62396
// Deprecation message should show the method name, not the type signature

interface Builder {
configure(value: string): Builder;
/** @deprecated use {@link Builder} instead */
oldMethod(): void;
}

declare function createBuilder(): Builder;

// When calling a deprecated method on the result of another call (chained call),
// the deprecation message should show the method name, not the type signature.
createBuilder().configure("x").oldMethod();