Skip to content

Commit 56c9459

Browse files
committed
Enable some perf optimizations now available to intersections
1 parent 9dec535 commit 56c9459

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/compiler/checker.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20789,10 +20789,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2078920789

2079020790
function typeRelatedToSomeType(source: Type, target: UnionOrIntersectionType, reportErrors: boolean): Ternary {
2079120791
const targetTypes = target.types;
20792+
if (target.flags & TypeFlags.UnionOrIntersection && containsType(targetTypes, source)) {
20793+
return Ternary.True;
20794+
}
2079220795
if (target.flags & TypeFlags.Union) {
20793-
if (containsType(targetTypes, source)) {
20794-
return Ternary.True;
20795-
}
2079620796
const match = getMatchingUnionConstituentForType(target as UnionType, source);
2079720797
if (match) {
2079820798
const related = isRelatedTo(source, match, RecursionFlags.Target, /*reportErrors*/ false);
@@ -20832,7 +20832,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2083220832

2083320833
function someTypeRelatedToType(source: UnionOrIntersectionType, target: Type, reportErrors: boolean, intersectionState: IntersectionState): Ternary {
2083420834
const sourceTypes = source.types;
20835-
if (source.flags & TypeFlags.Union && containsType(sourceTypes, target)) {
20835+
if (containsType(sourceTypes, target)) {
2083620836
return Ternary.True;
2083720837
}
2083820838
const len = sourceTypes.length;

0 commit comments

Comments
 (0)