microsoft / microsoft/TypeScript

TS2589 regression in 6.0: implements without type parameters causes excessive type instantiation when property uses concrete generic type

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

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

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

説明

🔎 Search Terms

Type instantiation is excessively deep and possibly infinite.

🕗 Version & Regression Information
  • This changed between versions 5.9.3 and 6.0.2
⏯ Playground Link

https://www.typescriptlang.org/play/?target=7#code/JYWwDg9gTgLgBDAnmApnA3nAShArjFKAGQgGMBDGYCAOwBo4B1FAIwGEJxaUaYBJXoQBm5UmgC+cIVE5wARAAEAbuXIATYDQD0M-ITkBuAFBGkqbHgIBRAB7wAvBjgBnFKSq0A-AC4XMKJoA5nDixkZaWnAAKgDKAEwArAAcAJxwtAgAFmikADbkzs5wam75UJTUNHAsKLkQAO4AdOGRAGLANr5QKGD5YnAABszsnJA0PPyCUCJiA3D1wDCZg8McXOO8AgTToigAPDh6tjAAfAPNES1wAHIQBL5LaIQyUOk0uYgIAYGBhEU1FFwrkGdQoHhoc2ARTMKDU80Wy3IcFItFI3QICGQKCuYHI5RAKG2cAAFANDtsSGDKgdLChjmcAJSNOAAVWcQUG5MIlIqtDmCyWljgSJhOLx5AJRLUEBQRRody+wB+hDgi2aKBskFgyPyhTgAFlEFZcigCbw4BqCDQ1EUABJRfVEY2miaq8Ams0wIqrUbcTZTGZodBGOBwUG8mg+Cx6YhkCM0o52E7GcRGIA

💻 Code
import type { RouterLocation, WebComponentInterface } from "@vaadin/router";

type RouteExt = { section?: string };

// TS2589 on the class declaration below.
// Fix: replace `WebComponentInterface` with `WebComponentInterface<RouteExt>`.
//
// Note: the error only triggers because `location` is typed with a concrete type
// parameter (`RouterLocation<RouteExt>`). Using `RouterLocation` without a type
// parameter does not trigger it.
export class MyElement extends HTMLElement implements WebComponentInterface {
  location?: RouterLocation<RouteExt>;
}
🙁 Actual behavior

I get this error:

Type instantiation is excessively deep and possibly infinite.

But the information isn't very useful to know what to do exactly in this case.

🙂 Expected behavior

Ideally no error, otherwise some more pointers about how to fix this.

Additional information about the issue

When running with --extendedDiagnostics:

typescript 5.9.3:

     Files:                         259
     Types:                      203241
     Instantiations:            2593860

typescript 6.0.2:

     Files:                         259
     Types:                      217322
     Instantiations:            5379836

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

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

はじめの一歩

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

調査の方向性

リンクされた Playground から始め、--extendedDiagnostics を使用して TypeScript 5.9.3 と 6.0.2 を比較し、implements 宣言と具体的な RouterLocation プロパティに焦点を当てます。TS2589 の原因となっている型インスタンス化の経路を追跡し、提供された再現例に対して結果を検証します。完了の条件は、例でエラーが報告されなくなるか、より実行可能な指針が示されることです。

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

評価

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

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

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