microsoft / microsoft/TypeScript

`symbolToNode` stack overflow when using recursive types and functions with type parameters

未关闭
#63,441 4 条评论 3 个 reaction 已指派 0 人 在 GitHub 查看
Bug Domain: check: Type Circularity
主要语言
Go
星标
111k
派生
14.3k
平均合并
2 天 4 小时
30 天内合并 PR
132

描述

### 🔎 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_

贡献指南

打开贡献指南

调研方向

首先在链接的复现用例上运行 tsc,并跟踪涉及递归泛型类型和函数的 symbolToNode 路径。确定递归转换在哪里达到调用栈限制,然后验证该复现用例在受影响的编译器版本中都能编译通过,且不会出现 Maximum call stack size exceeded 错误。

由索引模型根据 Issue 内容生成。

评估

技术栈
typescript
领域
compilers
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
48/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。