type-fest
type-fest copied to clipboard
Merge type increases type instantiations count drastically
trafficstars
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 [email protected]