Skip to content

Commit ee9c4dc

Browse files
committed
Merge pull request #5920 from Microsoft/fixUnionTypeInference
Fix slowdown in type inference involving union types
2 parents 0ab538f + c839dd3 commit ee9c4dc

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/compiler/checker.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6178,9 +6178,12 @@ namespace ts {
61786178
}
61796179
else {
61806180
source = getApparentType(source);
6181-
if (source.flags & TypeFlags.ObjectType && (target.flags & (TypeFlags.Reference | TypeFlags.Tuple) ||
6182-
(target.flags & TypeFlags.Anonymous) && target.symbol && target.symbol.flags & (SymbolFlags.Method | SymbolFlags.TypeLiteral | SymbolFlags.Class))) {
6183-
// If source is an object type, and target is a type reference, a tuple type, the type of a method, or a type literal, infer from members
6181+
if (source.flags & TypeFlags.ObjectType && (
6182+
target.flags & TypeFlags.Reference && (<TypeReference>target).typeArguments ||
6183+
target.flags & TypeFlags.Tuple ||
6184+
target.flags & TypeFlags.Anonymous && target.symbol && target.symbol.flags & (SymbolFlags.Method | SymbolFlags.TypeLiteral | SymbolFlags.Class))) {
6185+
// If source is an object type, and target is a type reference with type arguments, a tuple type,
6186+
// the type of a method, or a type literal, infer from members
61846187
if (isInProcess(source, target)) {
61856188
return;
61866189
}

0 commit comments

Comments
 (0)