Skip to content

symbolToNode stack overflow when using recursive types and functions with type parametersΒ #63441

@StyleShit

Description

@StyleShit

πŸ”Ž Search Terms

"symbolToNode", "stack overflow", "Maximum call stack size exceeded"

πŸ•— Version & Regression Information

This is happening in v5, v6, and tsgo (I didn't check prior versions)

⏯ Playground Link

No response

πŸ’» Code

Coming from typescript-eslint/typescript-eslint#11947, I created a reproduction that's agnostic to ESLint:

export interface CustomNode<P> {
  getNextNode: () => CustomNode<P>;
}

export declare const createNode: () => {
  getNextNode: <T>() => CustomNode<T>;
};

function wrapNode<T>(getNode: () => CustomNode<T>) {
  // ...
  // Wrapping logic here
  // ...

  return getNode;
}

wrapNode(() => {
  const node = createNode();

  return wrapNode<typeof node.getNextNode<any>>(node.getNextNode);
});

Full Repro and more details: https://github.com/StyleShit/repros/tree/main/ts-symbolToNode-stack-overflow

πŸ™ Actual behavior

Running tsc is failing with "Maximum call stack size exceeded" error

πŸ™‚ Expected behavior

Running tsc should not fail

Additional information about the issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: check: Type Circularitystackoverflows caused by circularities, or unexpected errors where no circularity appears to exist

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions