microsoft / microsoft/TypeScript

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

オープン
#63,441 コメント 4 件 リアクション 3 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Bug Domain: check: Type Circularity
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
2日 4時間
マージ済み PR(30日)
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_

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、リンクされた再現ケースに対して tsc を実行し、再帰的なジェネリック型と関数に関係する symbolToNode の経路を追跡します。再帰的な変換がコールスタックの上限に達する箇所を特定し、その後、影響を受けるコンパイラバージョン全体で、再現ケースが Maximum call stack size exceeded エラーなしにコンパイルできることを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
compilers
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
48/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。