4.7 regression: Array.flat(infinity) leads to "Type instantiation is excessively deep and possibly infinite." error
See original GitHub issueBug 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.
Issue Analytics
- State:
- Created a year ago
- Reactions:7
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Type instantiation is excessively deep and possibly infinite #22
Getting a ts error: Type instantiation is excessively deep and possibly infinite. ts(2589) Minimal example: import {flatten} from ...
Read more >Why am I getting "Type instantiation is excessively deep and ...
You'll notice in the Playground link that action has the error: "Type instantiation is excessively deep and possibly infinite".
Read more >Announcing TypeScript 4.7 : r/typescript - Reddit
It looks like the toughest upgrade though, I'm getting a lot of Type instantiation is excessively deep and possibly infinite errors.
Read more >gcc(1) - Linux manual page - man7.org
The gcc program accepts options and file names as operands. Many options have multi-letter names; therefore multiple single-letter options may not be grouped:...
Read more >d2l-en.pdf - Dive into Deep Learning
16.6.2 Text Pair Classification or Regression ... due to the rapid development of deep learning, some code in the print edition may not...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just ran into this as well, here’s a very concise example:
Same exact error on
args.flat(Infinity)
, “Type instantiation is excessively deep and possibly infinite.”A quick solution for now is to assert your
.flat
argument as an integer:args.flat(Infinity as 10)
Should make the error go away.
This could be addressed if a literal type for
Infinity
was added: playground link using1e309