@@ -2611,8 +2611,15 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
26112611 return addDeprecatedSuggestionWorker(declarations, diagnostic);
26122612 }
26132613
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);
26162623 return addDeprecatedSuggestionWorker(declaration, diagnostic);
26172624 }
26182625
@@ -37781,15 +37788,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3778137788 if (signature.declaration && signature.declaration.flags & NodeFlags.Deprecated) {
3778237789 const suggestionNode = getDeprecatedSuggestionNode(node);
3778337790 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);
3779337798 }
3779437799 }
3779537800
0 commit comments