Cache unnormalized intersection types#31476
Conversation
|
@typescript-bot test this & run dt |
|
Heya @ahejlsberg, I've started to run the extended test suite on this PR at 2c34672. You can monitor the build here. It should now contribute to this PR's status checks. |
|
@typescript-bot run dt |
|
Heya @ahejlsberg, I've started to run the parallelized Definitely Typed test suite on this PR at 2c34672. You can monitor the build here. It should now contribute to this PR's status checks. |
|
Should we consider doing the same for unions, since they potentially repeatedly invoke subtype reduction and/or literal reduction when normalized (which we likewise know is costly for large unions)? |
I tried. It doesn't seem to make much of a difference. In fact, since |
When creating intersection types we first normalize combinations of intersection and union types to place union types topmost. For example, this process turns
X & (A | B)into the equivalentX & A | X & B. The normalization process can be very costly for intersections involving large union types. With this PR we cache both unnormalized and normalized intersection types, where previously we would only cache the latter. This means that for a particular set of unnormalized input types, we will only perform the potentially expensive normalization process once.The improved caching lowers the check times for
reactandstyled-componentsby ~25% and makes our performance better than 3.3: