Microsoft/TypeScript

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

Open

#49.280 geöffnet am 27. Mai 2022

Auf GitHub ansehen
 (10 Kommentare) (15 Reaktionen) (0 zugewiesene Personen)TypeScript (6.726 Forks)batch import
BugCursed?Domain: check: Type CircularityHelp Wanted

Repository-Metriken

Stars
 (48.455 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 6T 17h) (9 gemergte PRs in 30 T)

Beschreibung

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.

Contributor Guide