Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 25 additions & 8 deletions packages/eslint-plugin/src/rules/no-deprecated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,37 @@ export default createRule<Options, MessageIds>({
? getJsDocDeprecation(symbol)
: undefined;
}

const seen = new Set<ts.Symbol>();
const targetSymbol = checker.getAliasedSymbol(symbol);
while (tsutils.isSymbolFlagSet(symbol, ts.SymbolFlags.Alias)) {
const reason = getJsDocDeprecation(symbol);
let current = symbol;

while (tsutils.isSymbolFlagSet(current, ts.SymbolFlags.Alias)) {
/* istanbul ignore next */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This'll need to be unit tested.

(I'm guessing you know this as a repeat contributor 😄 but just noting for tracking / in case someone else picks up this work)

if (seen.has(current)) {
break;
}

seen.add(current);

const reason = getJsDocDeprecation(current);

if (reason != null) {
return reason;
}
const immediateAliasedSymbol: ts.Symbol | undefined =
symbol.getDeclarations() && checker.getImmediateAliasedSymbol(symbol);
if (!immediateAliasedSymbol) {

const nextAlias: ts.Symbol | undefined =
current.getDeclarations() &&
checker.getImmediateAliasedSymbol(current);

if (!nextAlias) {
break;
}
symbol = immediateAliasedSymbol;
if (checkDeprecationsOfAliasedSymbol && symbol === targetSymbol) {
return getJsDocDeprecation(symbol);

current = nextAlias;

if (checkDeprecationsOfAliasedSymbol && current === targetSymbol) {
return getJsDocDeprecation(current);
}
}
return undefined;
Expand Down
Loading