Microsoft/TypeScript

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

开放

#49,280 创建于 2022年5月27日

 (10 条评论) (15 个反应) (0 位负责人)TypeScript (13,395 个派生)batch import
BugCursed?Domain: check: Type CircularityHelp Wanted

仓库指标

星标
 (108,860 个星标)
PR 合并指标
 (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.

贡献者指南