@@ -1198,6 +1198,10 @@ namespace ts {
11981198 return diagnostic;
11991199 }
12001200
1201+ function isDeprecatedSymbol(symbol: Symbol) {
1202+ return !!(getDeclarationNodeFlagsFromSymbol(symbol) & NodeFlags.Deprecated);
1203+ }
1204+
12011205 function addDeprecatedSuggestion(location: Node, declarations: Node[], deprecatedEntity: string) {
12021206 const diagnostic = createDiagnosticForNode(location, Diagnostics._0_is_deprecated, deprecatedEntity);
12031207 return addDeprecatedSuggestionWorker(declarations, diagnostic);
@@ -15184,7 +15188,7 @@ namespace ts {
1518415188 }
1518515189 const prop = getPropertyOfType(objectType, propName);
1518615190 if (prop) {
15187- if (accessFlags & AccessFlags.ReportDeprecated && accessNode && prop.declarations && getDeclarationNodeFlagsFromSymbol (prop) & NodeFlags.Deprecated && isUncalledFunctionReference(accessNode, prop)) {
15191+ if (accessFlags & AccessFlags.ReportDeprecated && accessNode && prop.declarations && isDeprecatedSymbol (prop) && isUncalledFunctionReference(accessNode, prop)) {
1518815192 const deprecatedNode = accessExpression?.argumentExpression ?? (isIndexedAccessTypeNode(accessNode) ? accessNode.indexType : accessNode);
1518915193 addDeprecatedSuggestion(deprecatedNode, prop.declarations, propName as string);
1519015194 }
@@ -25143,9 +25147,9 @@ namespace ts {
2514325147 }
2514425148
2514525149 const localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
25146- const sourceSymbol = localOrExportSymbol.flags & SymbolFlags.Alias ? resolveAlias (localOrExportSymbol) : localOrExportSymbol ;
25147- if (sourceSymbol.declarations && getDeclarationNodeFlagsFromSymbol(sourceSymbol ) & NodeFlags.Deprecated && isUncalledFunctionReference(node, sourceSymbol) ) {
25148- addDeprecatedSuggestion(node, sourceSymbol .declarations, node.escapedText as string);
25150+ const targetSymbol = checkDeprecatedAliasedSymbol (localOrExportSymbol, node) ;
25151+ if (isDeprecatedSymbol(targetSymbol ) && isUncalledFunctionReference(node, targetSymbol) && targetSymbol.declarations ) {
25152+ addDeprecatedSuggestion(node, targetSymbol .declarations, node.escapedText as string);
2514925153 }
2515025154
2515125155 let declaration = localOrExportSymbol.valueDeclaration;
@@ -28512,7 +28516,7 @@ namespace ts {
2851228516 }
2851328517 }
2851428518 else {
28515- if (prop.declarations && getDeclarationNodeFlagsFromSymbol (prop) & NodeFlags.Deprecated && isUncalledFunctionReference(node, prop)) {
28519+ if (isDeprecatedSymbol (prop) && isUncalledFunctionReference(node, prop) && prop.declarations ) {
2851628520 addDeprecatedSuggestion(right, prop.declarations, right.escapedText as string);
2851728521 }
2851828522 checkPropertyNotUsedBeforeDeclaration(prop, node, right);
@@ -39889,10 +39893,45 @@ namespace ts {
3988939893 }
3989039894 }
3989139895
39892- if (isImportSpecifier(node) && target.declarations?.every(d => !!(getCombinedNodeFlags(d) & NodeFlags.Deprecated))) {
39893- addDeprecatedSuggestion(node.name, target.declarations, symbol.escapedName as string);
39896+ if (isImportSpecifier(node)) {
39897+ const targetSymbol = checkDeprecatedAliasedSymbol(symbol, node);
39898+ if (isDeprecatedAliasedSymbol(targetSymbol) && targetSymbol.declarations) {
39899+ addDeprecatedSuggestion(node, targetSymbol.declarations, targetSymbol.escapedName as string);
39900+ }
39901+ }
39902+ }
39903+ }
39904+
39905+ function isDeprecatedAliasedSymbol(symbol: Symbol) {
39906+ return !!symbol.declarations && every(symbol.declarations, d => !!(getCombinedNodeFlags(d) & NodeFlags.Deprecated));
39907+ }
39908+
39909+ function checkDeprecatedAliasedSymbol(symbol: Symbol, location: Node) {
39910+ if (!(symbol.flags & SymbolFlags.Alias)) return symbol;
39911+
39912+ const targetSymbol = resolveAlias(symbol);
39913+ if (targetSymbol === unknownSymbol) return targetSymbol;
39914+
39915+ while (symbol.flags & SymbolFlags.Alias) {
39916+ const target = getImmediateAliasedSymbol(symbol);
39917+ if (target) {
39918+ if (target === targetSymbol) break;
39919+ if (target.declarations && length(target.declarations)) {
39920+ if (isDeprecatedAliasedSymbol(target)) {
39921+ addDeprecatedSuggestion(location, target.declarations, target.escapedName as string);
39922+ break;
39923+ }
39924+ else {
39925+ if (symbol === targetSymbol) break;
39926+ symbol = target;
39927+ }
39928+ }
39929+ }
39930+ else {
39931+ break;
3989439932 }
3989539933 }
39934+ return targetSymbol;
3989639935 }
3989739936
3989839937 function checkImportBinding(node: ImportEqualsDeclaration | ImportClause | NamespaceImport | ImportSpecifier) {
0 commit comments