-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Repeated conditional spreading of object literals results in OOM #40754
Comments
The two most obvious solutions are:
Edit: current plan is to do both. |
#34853 Originally handled objects with more than one key - it was just pared down to lower potential impact. If we have a good usecase, the fix can be broadened to objects with multiple keys. |
I think retaining the union is valuable if it's small - a few dozen shapes - but not if it's large. In the examples I'm looking at, they don't want the union at any size - the result is immediately cast to an uber type with all properties as optional. |
When a union is spread into a union, the sizes are multiplied, potentially resulting in an enormous union (especially if there are repeated spreads). This check detects cases that used to run out of memory. Fixes microsoft#40754
Just wanted to say that there are those of us who very much are interested in the individual shapes of 50+ literal objects in a union. I realise the performance impact though and perhaps our setup is sub-optimal, so maybe the solution for us would be to sacrifice some usability and create smaller unions that would have some overlap but would clear the bar. |
@MrAndersen1 can you tell me more about your use case? How many shapes do you usually need? Hundreds? Thousands? |
Follow-up question: if you're already doing this, are you having performance problems? |
@amcasey Oh no I don't expect us to ever breach 100. Usually old content gets removed which reduces the unions some. |
@MrAndersen1 50 is a made-up number, so I certainly have no objection to using 100 instead. 😄 I don't suppose you can share a link to your repo? |
@amcasey well, see, thats all up to you guys :) we did get issues on an earlier version of typescript, 3.7.3 I think it was, which I believe was due to some limit being hit. That could be resolved by updating to 4.0.2 however, which I was grateful for heh. No I can't share it sorry, would if I could. |
Sounds like we want to do something similar to reverting 7181c2a, probably in the 4.2 timeframe. |
Re-opening, since we decided to fix the perf issue too. |
The remaining work is targeting post-4.1. |
TypeScript Version: nightly (fc03982)
Search Terms: spread, union, oom
Playground Link: link
Related Issues: #34853 addressed a related issue
An internal partner team is using this to conditionally override CSS properties (e.g.
...sizeLimited && { width: 100, height: 100 }
and is seeing OOM crashes in tsc and poor editor responsiveness.The text was updated successfully, but these errors were encountered: