Microsoft/TypeScript

4.7 regression: Array.flat(infinity) leads to "Type instantiation is excessively deep and possibly infinite." error

Open

#49,280 建立於 2022年5月27日

在 GitHub 查看
 (10 留言) (15 反應) (0 負責人)TypeScript (6,726 fork)batch import
BugCursed?Domain: check: Type CircularityHelp Wanted

倉庫指標

Star
 (48,455 star)
PR 合併指標
 (平均合併 6天 17小時) (30 天內合併 9 個 PR)

描述

Bug Report

🔎 Search Terms

  • Array.flat
  • Type instantiation is excessively deep and possibly infinite.
  • Nested arrays

🕗 Version & Regression Information

  • This changed between versions 4.6 and 4.7

⏯ Playground Link

TypeScript Workbench with relevant code

💻 Code

interface Config {
  prop?: string;
}

interface ExtendedConfig extends Config {}

type NestedConfigs = Array<ExtendedConfig | NestedConfigs>;

const configs: NestedConfigs[] = [];

const flattened = configs.flat(Infinity);

🙁 Actual behavior

TypeScript raises the following error for the configs.flat(Infinity) call:

Type instantiation is excessively deep and possibly infinite. ts(2589)

🙂 Expected behavior

No error should be raised.

貢獻者指南