mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
fix(41295): handle deprecated callbacks (#41310)
This commit is contained in:
@@ -13844,9 +13844,14 @@ namespace ts {
|
||||
}
|
||||
|
||||
function isUncalledFunctionReference(node: Node, symbol: Symbol) {
|
||||
return !(symbol.flags & (SymbolFlags.Function | SymbolFlags.Method))
|
||||
|| !isCallLikeExpression(findAncestor(node, n => !isAccessExpression(n)) || node.parent)
|
||||
&& every(symbol.declarations, d => !isFunctionLike(d) || !!(getCombinedNodeFlags(d) & NodeFlags.Deprecated));
|
||||
if (symbol.flags & (SymbolFlags.Function | SymbolFlags.Method)) {
|
||||
const parent = findAncestor(node.parent, n => !isAccessExpression(n)) || node.parent;
|
||||
if (isCallLikeExpression(parent)) {
|
||||
return isCallOrNewExpression(parent) && isIdentifier(node) && hasMatchingArgument(parent, node);
|
||||
}
|
||||
return every(symbol.declarations, d => !isFunctionLike(d) || !!(getCombinedNodeFlags(d) & NodeFlags.Deprecated));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function getPropertyTypeForIndexType(originalObjectType: Type, objectType: Type, indexType: Type, fullIndexType: Type, suppressNoImplicitAnyError: boolean, accessNode: ElementAccessExpression | IndexedAccessTypeNode | PropertyName | BindingName | SyntheticExpression | undefined, accessFlags: AccessFlags, noUncheckedIndexedAccessCandidate?: boolean, reportDeprecated?: boolean) {
|
||||
@@ -20953,16 +20958,16 @@ namespace ts {
|
||||
return isMatchingReference(source, target) || containsMatchingReference(source, target);
|
||||
}
|
||||
|
||||
function hasMatchingArgument(callExpression: CallExpression, reference: Node) {
|
||||
if (callExpression.arguments) {
|
||||
for (const argument of callExpression.arguments) {
|
||||
function hasMatchingArgument(expression: CallExpression | NewExpression, reference: Node) {
|
||||
if (expression.arguments) {
|
||||
for (const argument of expression.arguments) {
|
||||
if (isOrContainsMatchingReference(reference, argument)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (callExpression.expression.kind === SyntaxKind.PropertyAccessExpression &&
|
||||
isOrContainsMatchingReference(reference, (<PropertyAccessExpression>callExpression.expression).expression)) {
|
||||
if (expression.expression.kind === SyntaxKind.PropertyAccessExpression &&
|
||||
isOrContainsMatchingReference(reference, (<PropertyAccessExpression>expression.expression).expression)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -22875,7 +22880,7 @@ namespace ts {
|
||||
|
||||
const localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
|
||||
const sourceSymbol = localOrExportSymbol.flags & SymbolFlags.Alias ? resolveAlias(localOrExportSymbol) : localOrExportSymbol;
|
||||
if (getDeclarationNodeFlagsFromSymbol(sourceSymbol) & NodeFlags.Deprecated && isUncalledFunctionReference(node.parent, sourceSymbol)) {
|
||||
if (getDeclarationNodeFlagsFromSymbol(sourceSymbol) & NodeFlags.Deprecated && isUncalledFunctionReference(node, sourceSymbol)) {
|
||||
errorOrSuggestion(/* isError */ false, node, Diagnostics._0_is_deprecated, node.escapedText as string);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user