Skip to content

Commit a2928b8

Browse files
committed
Optimize relationship checks for arrays and tuples
1 parent 1fb6f11 commit a2928b8

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11829,6 +11829,9 @@ namespace ts {
1182911829
errorInfo = saveErrorInfo;
1183011830
}
1183111831
}
11832+
else if (isTupleType(source) && (isArrayType(target) || isReadonlyArrayType(target)) || isArrayType(source) && isReadonlyArrayType(target)) {
11833+
return isRelatedTo(getIndexTypeOfType(source, IndexKind.Number) || anyType, getIndexTypeOfType(target, IndexKind.Number) || anyType, reportErrors);
11834+
}
1183211835
// Even if relationship doesn't hold for unions, intersections, or generic type references,
1183311836
// it may hold in a structural comparison.
1183411837
// In a check of the form X = A & B, we will have previously checked if A relates to X or B relates

0 commit comments

Comments
 (0)