Slow build time on union of enums type as a parameter of generic function. #43899
Labels
Bug
A bug in TypeScript
Domain: Big Unions
The root cause is ultimately that big unions interact poorly with complex structures
Domain: Performance
Reports of unusually slow behavior
Fix Available
A PR has been opened for this issue
Milestone
Uh oh!
There was an error while loading. Please reload this page.
Bug Report
Type checking for generic function which the parameter it being specialized with a union of enum and other types has a huge build time.
🔎 Search Terms
big enum, union, performance, slow
🕗 Version & Regression Information
Confirmed with 4.2.4, and recent master branch.( less than one week old)
We started to noticed this slow build from March.
💻 Code
🙁 Actual behavior
The build time for a similar code is huge, and it scales up to 10-20 seconds solely for checking the expression similar to
generic(param || something_else)
. The TS library which contains thousands lines of code takes > 200 seconds to build. This is production code and not a made up example.🙂 Expected behavior
Checking one expression should take much less time, maybe in a scale of hundreds of milliseconds.
Diagnosis
This seems to be a combination of several things.
ts.checkCallExpression
on call expressions which are generic, it tries to sqaush the type(in the above casetype A
) if it's union, and try to get a common super type of all it's elements.The text was updated successfully, but these errors were encountered: