@@ -1194,6 +1194,10 @@ namespace ts {
11941194 return diagnostic;
11951195 }
11961196
1197+ function isDeprecatedSymbol(symbol: Symbol) {
1198+ return !!(getDeclarationNodeFlagsFromSymbol(symbol) & NodeFlags.Deprecated);
1199+ }
1200+
11971201 function addDeprecatedSuggestion(location: Node, declarations: Node[], deprecatedEntity: string) {
11981202 const diagnostic = createDiagnosticForNode(location, Diagnostics._0_is_deprecated, deprecatedEntity);
11991203 return addDeprecatedSuggestionWorker(declarations, diagnostic);
@@ -15175,7 +15179,7 @@ namespace ts {
1517515179 }
1517615180 const prop = getPropertyOfType(objectType, propName);
1517715181 if (prop) {
15178- if (accessFlags & AccessFlags.ReportDeprecated && accessNode && prop.declarations && getDeclarationNodeFlagsFromSymbol (prop) & NodeFlags.Deprecated && isUncalledFunctionReference(accessNode, prop)) {
15182+ if (accessFlags & AccessFlags.ReportDeprecated && accessNode && prop.declarations && isDeprecatedSymbol (prop) && isUncalledFunctionReference(accessNode, prop)) {
1517915183 const deprecatedNode = accessExpression?.argumentExpression ?? (isIndexedAccessTypeNode(accessNode) ? accessNode.indexType : accessNode);
1518015184 addDeprecatedSuggestion(deprecatedNode, prop.declarations, propName as string);
1518115185 }
@@ -25066,9 +25070,9 @@ namespace ts {
2506625070 }
2506725071
2506825072 const localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
25069- const sourceSymbol = localOrExportSymbol.flags & SymbolFlags.Alias ? resolveAlias (localOrExportSymbol) : localOrExportSymbol ;
25070- if (sourceSymbol.declarations && getDeclarationNodeFlagsFromSymbol(sourceSymbol ) & NodeFlags.Deprecated && isUncalledFunctionReference(node, sourceSymbol) ) {
25071- addDeprecatedSuggestion(node, sourceSymbol .declarations, node.escapedText as string);
25073+ const targetSymbol = checkDeprecatedAliasedSymbol (localOrExportSymbol, node) ;
25074+ if (isDeprecatedSymbol(targetSymbol ) && isUncalledFunctionReference(node, targetSymbol) && targetSymbol.declarations ) {
25075+ addDeprecatedSuggestion(node, targetSymbol .declarations, node.escapedText as string);
2507225076 }
2507325077
2507425078 let declaration = localOrExportSymbol.valueDeclaration;
@@ -28460,7 +28464,7 @@ namespace ts {
2846028464 }
2846128465 }
2846228466 else {
28463- if (prop.declarations && getDeclarationNodeFlagsFromSymbol (prop) & NodeFlags.Deprecated && isUncalledFunctionReference(node, prop)) {
28467+ if (isDeprecatedSymbol (prop) && isUncalledFunctionReference(node, prop) && prop.declarations ) {
2846428468 addDeprecatedSuggestion(right, prop.declarations, right.escapedText as string);
2846528469 }
2846628470 checkPropertyNotUsedBeforeDeclaration(prop, node, right);
@@ -39802,10 +39806,45 @@ namespace ts {
3980239806 }
3980339807 }
3980439808
39805- if (isImportSpecifier(node) && target.declarations?.every(d => !!(getCombinedNodeFlags(d) & NodeFlags.Deprecated))) {
39806- addDeprecatedSuggestion(node.name, target.declarations, symbol.escapedName as string);
39809+ if (isImportSpecifier(node)) {
39810+ const targetSymbol = checkDeprecatedAliasedSymbol(symbol, node);
39811+ if (isDeprecatedAliasedSymbol(targetSymbol) && targetSymbol.declarations) {
39812+ addDeprecatedSuggestion(node, targetSymbol.declarations, targetSymbol.escapedName as string);
39813+ }
39814+ }
39815+ }
39816+ }
39817+
39818+ function isDeprecatedAliasedSymbol(symbol: Symbol) {
39819+ return !!symbol.declarations && every(symbol.declarations, d => !!(getCombinedNodeFlags(d) & NodeFlags.Deprecated));
39820+ }
39821+
39822+ function checkDeprecatedAliasedSymbol(symbol: Symbol, location: Node) {
39823+ if (!(symbol.flags & SymbolFlags.Alias)) return symbol;
39824+
39825+ const targetSymbol = resolveAlias(symbol);
39826+ if (targetSymbol === unknownSymbol) return targetSymbol;
39827+
39828+ while (symbol.flags & SymbolFlags.Alias) {
39829+ const target = getImmediateAliasedSymbol(symbol);
39830+ if (target) {
39831+ if (target === targetSymbol) break;
39832+ if (target.declarations && length(target.declarations)) {
39833+ if (isDeprecatedAliasedSymbol(target)) {
39834+ addDeprecatedSuggestion(location, target.declarations, target.escapedName as string);
39835+ break;
39836+ }
39837+ else {
39838+ if (symbol === targetSymbol) break;
39839+ symbol = target;
39840+ }
39841+ }
39842+ }
39843+ else {
39844+ break;
3980739845 }
3980839846 }
39847+ return targetSymbol;
3980939848 }
3981039849
3981139850 function checkImportBinding(node: ImportEqualsDeclaration | ImportClause | NamespaceImport | ImportSpecifier) {
0 commit comments