microsoft / microsoft/TypeScript

`get self(): this` in an interface crashes the checker (6.0 regression)

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

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

Fixed
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
2日 4時間
マージ済み PR(30日)
132

説明

### 🔎 Search Terms

getConditionalFlowTypeOfType, getAnnotatedAccessorType, Cannot read properties of undefined (reading 'flags'), accessor this type

### 🕗 Version & Regression Information

- Crashes in 6.0.3 and nightly (6.0.0-dev.20260416); 5.9.3 is clean — a 6.0 regression

### 💻 Code

```ts
interface I {
get self(): this
}
```

### 🙁 Actual behavior

`tsc` crashes:

```
TypeError: Cannot read properties of undefined (reading 'flags')
at getConditionalFlowTypeOfType (typescript/lib/_tsc.js:65892:23)
at getTypeFromTypeNode (typescript/lib/_tsc.js:68622:12)
at getAnnotatedAccessorType (typescript/lib/_tsc.js:62162:20)
at getTypeOfAccessors (typescript/lib/_tsc.js:62180:99)
at checkAccessorDeclarationDiagnostics (typescript/lib/_tsc.js:87089:26)
```

Any `this` nested inside the accessor's return type annotation triggers it too (`get pair(): [this, string]`). A method or property signature with the same `this` type is fine.

### 🙂 Expected behavior

No crash (5.9 checks this without errors).

### Additional information about the issue

_No response_

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

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

はじめの一歩

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

調査の方向性

インターフェースのスニペットと報告された accessor のケースを使ってクラッシュを再現します。報告された checker stack の getAnnotatedAccessorType、getTypeOfAccessors、getConditionalFlowTypeOfType から調査を始め、対応する TypeScript ソースと回帰テストのセットアップを見つけます。これらの accessor がクラッシュしなくなり、既存の 5.9 の動作がテストで引き続きカバーされていれば完了です。

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

評価

技術スタック
typescript
領域
compilers
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
静か
明瞭さ
明確に書かれている
初心者へのやさしさ
68/100

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

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