diff --git a/packages/eslint-plugin/src/rules/no-deprecated.ts b/packages/eslint-plugin/src/rules/no-deprecated.ts index 71b333488b55..6d7e24d7e5f0 100644 --- a/packages/eslint-plugin/src/rules/no-deprecated.ts +++ b/packages/eslint-plugin/src/rules/no-deprecated.ts @@ -89,20 +89,37 @@ export default createRule({ ? getJsDocDeprecation(symbol) : undefined; } + + const seen = new Set(); 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 */ + 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;