Skip to content
Permalink
Browse files

fix(eslint-plugin): [explicit-module-boundary-types] cyclical referen…

…ce infinite recursion crash (#2482)

Co-authored-by: Tadhg McDonald-Jensen <tadhg.mcdonaldjensen@carleton.ca>
  • Loading branch information
tadhgmister and Tadhg McDonald-Jensen committed Sep 6, 2020
1 parent 3d07a99 commit 86936537bd6f1075cbceeb8d2d4e254d75188409
@@ -96,6 +96,10 @@ export default util.createRule<Options, MessageIds>({
// tracks functions that were found whilst traversing
const foundFunctions: FunctionNode[] = [];

// all nodes visited, avoids infinite recursion for cyclic references
// (such as class member referring to itself)
const alreadyVisited = new Set<TSESTree.Node>();

/*
# How the rule works:
@@ -311,9 +315,10 @@ export default util.createRule<Options, MessageIds>({
}

function checkNode(node: TSESTree.Node | null): void {
if (node == null) {
if (node == null || alreadyVisited.has(node)) {
return;
}
alreadyVisited.add(node);

switch (node.type) {
case AST_NODE_TYPES.ArrowFunctionExpression:
@@ -654,6 +654,11 @@ export abstract class Foo<T> {
`
export declare class Foo {
set time(seconds: number);
}
`,
`
export class A {
b = A;
}
`,
],

0 comments on commit 8693653

Please sign in to comment.