Properly account for intersections in getKeyPropertyName#63117
Properly account for intersections in getKeyPropertyName#63117Andarist wants to merge 1 commit intomicrosoft:mainfrom
getKeyPropertyName#63117Conversation
|
This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise. |
| if ( | ||
| types.length < 10 || getObjectFlags(unionType) & ObjectFlags.PrimitiveUnion || | ||
| countWhere(types, t => !!(t.flags & (TypeFlags.Object | TypeFlags.InstantiableNonPrimitive))) < 10 | ||
| countWhere(types, t => !!(t.flags & (TypeFlags.Object | TypeFlags.Intersection | TypeFlags.InstantiableNonPrimitive))) < 10 |
There was a problem hiding this comment.
This condition matches now the existing flags check in mapTypesByKeyProperty (that function is already called only from within the containing function here - getKeyPropertyName)
|
@typescript-bot test it |
|
Hey @jakebailey, the results of running the DT tests are ready. Everything looks the same! |
|
@jakebailey Here are the results of running the user tests with tsc comparing There were infrastructure failures potentially unrelated to your change:
Otherwise... Everything looks good! |
|
@jakebailey Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@jakebailey Here are the results of running the top 400 repos with tsc comparing Everything looks good! |
In the code below,
getMatchingUnionConstituentForType(and thustypeRelatedToSomeType) can't benefit from the key property optimization. So in certain situations (like this one) the source has to be related to each constituent of the target union (until it finds a match) - but it should be able to find the matching constituent using a fast path.This issue affects
test1. I've includedtest2for comparison purposes - the optimization kicks in there.TS playground: