Skip to content

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

Open

Description

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptCursed?It's likely this is extremely difficult to fix without making something else much, much worseHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions