Skip to content

fix(eslint-plugin): [no-deprecated] max callstack exceeded when class implements itself #10040

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
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
11 changes: 8 additions & 3 deletions packages/eslint-plugin/src/rules/no-deprecated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,14 @@ export default createRule({
function getJsDocDeprecation(
symbol: ts.Signature | ts.Symbol | undefined,
): string | undefined {
const tag = symbol
?.getJsDocTags(checker)
.find(tag => tag.name === 'deprecated');
let jsDocTags: ts.JSDocTagInfo[] | undefined;
try {
jsDocTags = symbol?.getJsDocTags(checker);
} catch {
// workaround for https://github.com/microsoft/TypeScript/issues/60024
return;
}
const tag = jsDocTags?.find(tag => tag.name === 'deprecated');

if (!tag) {
return undefined;
Expand Down
14 changes: 14 additions & 0 deletions packages/eslint-plugin/tests/rules/no-deprecated.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,20 @@ ruleTester.run('no-deprecated', rule, {
},
},
'call();',

// this test is to ensure the rule doesn't crash when class implements itself
// https://github.com/typescript-eslint/typescript-eslint/issues/10031
`
class Foo implements Foo {
get bar(): number {
return 42;
}

baz(): number {
return this.bar;
}
}
`,
],
invalid: [
{
Expand Down
Loading