Skip to content

Commit 7a216fe

Browse files
authored
fix(eslint-plugin): [no-deprecated] max callstack exceeded when class implements itself (#10040)
1 parent 53650c4 commit 7a216fe

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

‎packages/eslint-plugin/src/rules/no-deprecated.ts‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,14 @@ export default createRule({
152152
function getJsDocDeprecation(
153153
symbol: ts.Signature | ts.Symbol | undefined,
154154
): string | undefined {
155-
const tag = symbol
156-
?.getJsDocTags(checker)
157-
.find(tag => tag.name === 'deprecated');
155+
let jsDocTags: ts.JSDocTagInfo[] | undefined;
156+
try {
157+
jsDocTags = symbol?.getJsDocTags(checker);
158+
} catch {
159+
// workaround for https://github.com/microsoft/TypeScript/issues/60024
160+
return;
161+
}
162+
const tag = jsDocTags?.find(tag => tag.name === 'deprecated');
158163

159164
if (!tag) {
160165
return undefined;

‎packages/eslint-plugin/tests/rules/no-deprecated.test.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,20 @@ ruleTester.run('no-deprecated', rule, {
253253
},
254254
},
255255
'call();',
256+
257+
// this test is to ensure the rule doesn't crash when class implements itself
258+
// https://github.com/typescript-eslint/typescript-eslint/issues/10031
259+
`
260+
class Foo implements Foo {
261+
get bar(): number {
262+
return 42;
263+
}
264+
265+
baz(): number {
266+
return this.bar;
267+
}
268+
}
269+
`,
256270
],
257271
invalid: [
258272
{

0 commit comments

Comments
 (0)