@@ -2611,8 +2611,15 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2611
2611
return addDeprecatedSuggestionWorker(declarations, diagnostic);
2612
2612
}
2613
2613
2614
- function addDeprecatedSuggestionWithSignature(location: Node, declaration: Node, deprecatedEntity: string) {
2615
- const diagnostic = createDiagnosticForNode(location, Diagnostics._0_is_deprecated, deprecatedEntity);
2614
+ function addDeprecatedSuggestionWithSignature(location: Node, declaration: Node, deprecatedEntity: string | undefined, signatureString: string, invoked?: Expression) {
2615
+ let nameFromInvoked = "<unknown>";
2616
+ if (invoked && invoked.kind === SyntaxKind.PropertyAccessExpression) {
2617
+ const propAccess = invoked as PropertyAccessExpression;
2618
+ nameFromInvoked = (propAccess.name as any).getText() + "()";
2619
+ }
2620
+ const diagnostic = deprecatedEntity
2621
+ ? createDiagnosticForNode(location, Diagnostics.The_signature_0_of_1_is_deprecated, signatureString, deprecatedEntity)
2622
+ : createDiagnosticForNode(location, Diagnostics._0_is_deprecated, nameFromInvoked);
2616
2623
return addDeprecatedSuggestionWorker(declaration, diagnostic);
2617
2624
}
2618
2625
@@ -37781,15 +37788,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
37781
37788
if (signature.declaration && signature.declaration.flags & NodeFlags.Deprecated) {
37782
37789
const suggestionNode = getDeprecatedSuggestionNode(node);
37783
37790
const invoked = getInvokedExpression(node);
37784
- let name = tryGetPropertyAccessOrIdentifierToString(invoked);
37785
-
37786
- if (!name && invoked.kind === SyntaxKind.PropertyAccessExpression) {
37787
- const propAccess = invoked as PropertyAccessExpression;
37788
- name = (propAccess.name as any).getText() + "()";
37789
- }
37790
- name = name ?? "<unknown>";
37791
-
37792
- addDeprecatedSuggestionWithSignature(suggestionNode, signature.declaration, name);
37791
+ const invokedExpr = invoked &&
37792
+ invoked.kind !== SyntaxKind.JsxElement &&
37793
+ invoked.kind !== SyntaxKind.JsxSelfClosingElement
37794
+ ? (invoked as Expression)
37795
+ : undefined;
37796
+ const name = tryGetPropertyAccessOrIdentifierToString(invoked);
37797
+ addDeprecatedSuggestionWithSignature(suggestionNode, signature.declaration, name, signatureToString(signature), invokedExpr);
37793
37798
}
37794
37799
}
37795
37800
0 commit comments