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.

贡献者指南