Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge type increases type instantiations count drastically #304

Closed
chbdetta opened this issue Oct 29, 2021 · 0 comments · Fixed by #455
Closed

Merge type increases type instantiations count drastically #304

chbdetta opened this issue Oct 29, 2021 · 0 comments · Fixed by #455
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@chbdetta
Copy link

chbdetta commented Oct 29, 2021

I ran into error TS2589: Type instantiation is excessively deep and possibly infinite. and get this result with --extendedDiagnostics:

Files:                        1527
Lines of Library:            28535
Lines of Definitions:        76407
Lines of TypeScript:         17557
Lines of JavaScript:        195957
Lines of JSON:                   0
Lines of Other:                  0
Nodes of Library:           117553
Nodes of Definitions:       273566
Nodes of TypeScript:         72611
Nodes of JavaScript:        825495
Nodes of JSON:                   0
Nodes of Other:                  0
Identifiers:                431173
Symbols:                    410281
Types:                       90155
Instantiations:            6707979            <========== the instantiations count exceeds the limitation
Memory used:               531849K
Assignability cache size:    53667
Identity cache size:          1231
Subtype cache size:           1904
Strict subtype cache size:    8066

tsc has a 5 million limitation on instantiation counts

After I replace all the Merge with simple intersection with Omit, I get this:

Files:                        1527
Lines of Library:            28535
Lines of Definitions:        76407
Lines of TypeScript:         17522
Lines of JavaScript:        195957
Lines of JSON:                   0
Lines of Other:                  0
Nodes of Library:           117553
Nodes of Definitions:       273566
Nodes of TypeScript:         72570
Nodes of JavaScript:        825495
Nodes of JSON:                   0
Nodes of Other:                  0
Identifiers:                431152
Symbols:                    448585
Types:                       80108
Instantiations:             514523         <========== 10x smaller
Memory used:               556046K
Assignability cache size:    77690
Identity cache size:          1259
Subtype cache size:           2096
Strict subtype cache size:    8430

Using type-fest@2.3.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants