@@ -13284,13 +13284,19 @@ namespace ts {
13284
13284
undefined;
13285
13285
}
13286
13286
13287
+ function isUncalledFunctionReference(node: Node, symbol: Symbol) {
13288
+ return !(symbol.flags & (SymbolFlags.Function | SymbolFlags.Method))
13289
+ || !isCallLikeExpression(findAncestor(node, n => !isAccessExpression(n)) || node.parent)
13290
+ && every(symbol.declarations, d => !isFunctionLike(d) || !!(d.flags & NodeFlags.Deprecated));
13291
+ }
13292
+
13287
13293
function getPropertyTypeForIndexType(originalObjectType: Type, objectType: Type, indexType: Type, fullIndexType: Type, suppressNoImplicitAnyError: boolean, accessNode: ElementAccessExpression | IndexedAccessTypeNode | PropertyName | BindingName | SyntheticExpression | undefined, accessFlags: AccessFlags) {
13288
13294
const accessExpression = accessNode && accessNode.kind === SyntaxKind.ElementAccessExpression ? accessNode : undefined;
13289
13295
const propName = accessNode && isPrivateIdentifier(accessNode) ? undefined : getPropertyNameFromIndex(indexType, accessNode);
13290
13296
if (propName !== undefined) {
13291
13297
const prop = getPropertyOfType(objectType, propName);
13292
13298
if (prop) {
13293
- if (accessNode && prop.flags & SymbolFlags .Deprecated) {
13299
+ if (accessNode && prop.valueDeclaration?. flags & NodeFlags .Deprecated && isUncalledFunctionReference(accessNode, prop) ) {
13294
13300
const deprecatedNode = accessExpression?.argumentExpression ?? (isIndexedAccessTypeNode(accessNode) ? accessNode.indexType : accessNode);
13295
13301
errorOrSuggestion(/* isError */ false, deprecatedNode, Diagnostics._0_is_deprecated, propName as string);
13296
13302
}
@@ -22055,9 +22061,8 @@ namespace ts {
22055
22061
const localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
22056
22062
let declaration: Declaration | undefined = localOrExportSymbol.valueDeclaration;
22057
22063
22058
- const target = (symbol.flags & SymbolFlags.Alias ? resolveAlias(symbol) : symbol);
22059
- if (target.flags & SymbolFlags.Deprecated) {
22060
- errorOrSuggestion(/* isError */ false, node, Diagnostics._0_is_deprecated, node.escapedText as string);
22064
+ if (declaration?.flags & NodeFlags.Deprecated && isUncalledFunctionReference(node.parent, localOrExportSymbol)) {
22065
+ errorOrSuggestion(/* isError */ false, node, Diagnostics._0_is_deprecated, node.escapedText as string);;
22061
22066
}
22062
22067
if (localOrExportSymbol.flags & SymbolFlags.Class) {
22063
22068
// Due to the emit for class decorators, any reference to the class from inside of the class body
@@ -24604,6 +24609,7 @@ namespace ts {
24604
24609
if (isNodeOpeningLikeElement) {
24605
24610
const jsxOpeningLikeNode = node as JsxOpeningLikeElement;
24606
24611
const sig = getResolvedSignature(jsxOpeningLikeNode);
24612
+ checkDeprecatedSignature(sig, node);
24607
24613
checkJsxReturnAssignableToAppropriateBound(getJsxReferenceKind(jsxOpeningLikeNode), getReturnTypeOfSignature(sig), jsxOpeningLikeNode);
24608
24614
}
24609
24615
}
@@ -25032,7 +25038,7 @@ namespace ts {
25032
25038
propType = indexInfo.type;
25033
25039
}
25034
25040
else {
25035
- if (prop.flags & SymbolFlags .Deprecated) {
25041
+ if (prop.valueDeclaration?. flags & NodeFlags .Deprecated && isUncalledFunctionReference(node, prop) ) {
25036
25042
errorOrSuggestion(/* isError */ false, right, Diagnostics._0_is_deprecated, right.escapedText as string);
25037
25043
}
25038
25044
@@ -27424,6 +27430,8 @@ namespace ts {
27424
27430
return nonInferrableType;
27425
27431
}
27426
27432
27433
+ checkDeprecatedSignature(signature, node);
27434
+
27427
27435
if (node.expression.kind === SyntaxKind.SuperKeyword) {
27428
27436
return voidType;
27429
27437
}
@@ -27483,6 +27491,12 @@ namespace ts {
27483
27491
return returnType;
27484
27492
}
27485
27493
27494
+ function checkDeprecatedSignature(signature: Signature, node: Node) {
27495
+ if (signature.declaration && signature.declaration.flags & NodeFlags.Deprecated) {
27496
+ errorOrSuggestion(/*isError*/ false, node, Diagnostics._0_is_deprecated, signatureToString(signature));
27497
+ }
27498
+ }
27499
+
27486
27500
function isSymbolOrSymbolForCall(node: Node) {
27487
27501
if (!isCallExpression(node)) return false;
27488
27502
let left = node.expression;
@@ -27591,7 +27605,9 @@ namespace ts {
27591
27605
if (languageVersion < ScriptTarget.ES2015) {
27592
27606
checkExternalEmitHelpers(node, ExternalEmitHelpers.MakeTemplateObject);
27593
27607
}
27594
- return getReturnTypeOfSignature(getResolvedSignature(node));
27608
+ const signature = getResolvedSignature(node);
27609
+ checkDeprecatedSignature(signature, node);
27610
+ return getReturnTypeOfSignature(signature);
27595
27611
}
27596
27612
27597
27613
function checkAssertion(node: AssertionExpression) {
@@ -30867,7 +30883,7 @@ namespace ts {
30867
30883
}
30868
30884
const symbol = getNodeLinks(node).resolvedSymbol;
30869
30885
if (symbol) {
30870
- if (symbol.flags & SymbolFlags .Deprecated) {
30886
+ if (every( symbol.declarations, d => !isTypeDeclaration(d) || !!(d. flags & NodeFlags .Deprecated)) ) {
30871
30887
const diagLocation = isTypeReferenceNode(node) && isQualifiedName(node.typeName) ? node.typeName.right : node;
30872
30888
errorOrSuggestion(/* isError */ false, diagLocation, Diagnostics._0_is_deprecated, symbol.escapedName as string);
30873
30889
}
@@ -31719,6 +31735,7 @@ namespace ts {
31719
31735
/** Check a decorator */
31720
31736
function checkDecorator(node: Decorator): void {
31721
31737
const signature = getResolvedSignature(node);
31738
+ checkDeprecatedSignature(signature, node);
31722
31739
const returnType = getReturnTypeOfSignature(signature);
31723
31740
if (returnType.flags & TypeFlags.Any) {
31724
31741
return;
@@ -35212,7 +35229,9 @@ namespace ts {
35212
35229
}
35213
35230
}
35214
35231
35215
- if (isImportSpecifier(node) && target.flags & SymbolFlags.Deprecated) {
35232
+ if (isImportSpecifier(node) &&
35233
+ (target.valueDeclaration && target.valueDeclaration.flags & NodeFlags.Deprecated
35234
+ || every(target.declarations, d => !!(d.flags & NodeFlags.Deprecated)))) {
35216
35235
errorOrSuggestion(/* isError */ false, node.name, Diagnostics._0_is_deprecated, symbol.escapedName as string);
35217
35236
}
35218
35237
}
0 commit comments