microsoft / microsoft/TypeScript

Inconsistent error messages with circular base type argument

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

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

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

説明

I noticed here that a type argument to a base class can reference property types in the same class, so I wondered what would happen if I tried to reference an inherited property type that itself depends on the type argument. To its credit, the compiler didn't crash, but the errors I got didn't make much sense.

TypeScript Version: master (e1a4c2779f93c8389d1589e543920a61771e97ec)

Search Terms: circular self referential base extends type argument property same class lookup type

Code

class Super<T> {
  foo!: T;
}
class Sub extends Super<Sub["bar"]> {
  bar!: Sub["foo"];  // Actual: Error: "Property 'foo' does not exist on type 'Sub'."
  baz!: Sub["foo"];  // Actual: No error
}

Expected behavior: An error that indicates that circular type annotations are involved.

Actual behavior: As marked.

Playground Link: link

Related Issues: None found, but this is hard to search for.

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

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

はじめの一歩

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

調査の方向性

報告に示されている TypeScript の master リビジョンを使用して、提供された Playground Link から不一致を再現し、その後、循環する基底型引数に対するコンパイラーの動作を追跡します。barbaz のケースが、現在の一致しない結果ではなく、循環する型注釈が関与していることを示す一貫した診断を受け取れば完了です。

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

評価

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

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

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