microsoft / microsoft/TypeScript
`symbolToNode` stack overflow when using recursive types and functions with type parameters
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
### 🔎 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 https://github.com/typescript-eslint/typescript-eslint/issues/11947, I created a reproduction that's agnostic to ESLint:
```ts
export interface CustomNode
{
getNextNode: () => CustomNode
;
}
export declare const createNode: () => {
getNextNode: () => CustomNode;
};
function wrapNode(getNode: () => CustomNode) {
// ...
// Wrapping logic here
// ...
return getNode;
}
wrapNode(() => {
const node = createNode();
return wrapNode>(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_
Contributor guide
Research direction
Start by running tsc on the linked reproduction and tracing the symbolToNode path involved in the recursive generic types and functions. Identify where the recursive conversion reaches the call-stack limit, then verify that the reproduction compiles without a Maximum call stack size exceeded error across the affected compiler versions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100