@@ -1198,6 +1198,10 @@ namespace ts {
1198
1198
return diagnostic;
1199
1199
}
1200
1200
1201
+ function isDeprecatedSymbol(symbol: Symbol) {
1202
+ return !!(getDeclarationNodeFlagsFromSymbol(symbol) & NodeFlags.Deprecated);
1203
+ }
1204
+
1201
1205
function addDeprecatedSuggestion(location: Node, declarations: Node[], deprecatedEntity: string) {
1202
1206
const diagnostic = createDiagnosticForNode(location, Diagnostics._0_is_deprecated, deprecatedEntity);
1203
1207
return addDeprecatedSuggestionWorker(declarations, diagnostic);
@@ -15184,7 +15188,7 @@ namespace ts {
15184
15188
}
15185
15189
const prop = getPropertyOfType(objectType, propName);
15186
15190
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)) {
15188
15192
const deprecatedNode = accessExpression?.argumentExpression ?? (isIndexedAccessTypeNode(accessNode) ? accessNode.indexType : accessNode);
15189
15193
addDeprecatedSuggestion(deprecatedNode, prop.declarations, propName as string);
15190
15194
}
@@ -25143,9 +25147,9 @@ namespace ts {
25143
25147
}
25144
25148
25145
25149
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);
25149
25153
}
25150
25154
25151
25155
let declaration = localOrExportSymbol.valueDeclaration;
@@ -28512,7 +28516,7 @@ namespace ts {
28512
28516
}
28513
28517
}
28514
28518
else {
28515
- if (prop.declarations && getDeclarationNodeFlagsFromSymbol (prop) & NodeFlags.Deprecated && isUncalledFunctionReference(node, prop)) {
28519
+ if (isDeprecatedSymbol (prop) && isUncalledFunctionReference(node, prop) && prop.declarations ) {
28516
28520
addDeprecatedSuggestion(right, prop.declarations, right.escapedText as string);
28517
28521
}
28518
28522
checkPropertyNotUsedBeforeDeclaration(prop, node, right);
@@ -39889,10 +39893,45 @@ namespace ts {
39889
39893
}
39890
39894
}
39891
39895
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;
39894
39932
}
39895
39933
}
39934
+ return targetSymbol;
39896
39935
}
39897
39936
39898
39937
function checkImportBinding(node: ImportEqualsDeclaration | ImportClause | NamespaceImport | ImportSpecifier) {
0 commit comments