Skip to content

Commit 40ebaee

Browse files
committed
brign back comments
1 parent 83bab0d commit 40ebaee

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/compiler/checker.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29347,6 +29347,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2934729347
mapType(
2934829348
candidate,
2934929349
c => {
29350+
// For each constituent t in the current type, if t and and c are directly related, pick the most
29351+
// specific of the two. When t and c are related in both directions, we prefer c for type predicates
29352+
// because that is the asserted type, but t for `instanceof` because generics aren't reflected in
29353+
// prototype object types.
2935029354
const directlyRelated = checkDerived ?
2935129355
(isTypeDerivedFrom(t, c) ? t : isTypeDerivedFrom(c, t) ? c : neverType) :
2935229356
(isTypeStrictSubtypeOf(t, c) ? t : isTypeStrictSubtypeOf(c, t) ? c : isTypeSubtypeOf(t, c) ? t : isTypeSubtypeOf(c, t) ? c : neverType);
@@ -29357,6 +29361,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2935729361
},
2935829362
));
2935929363
if (matchedCandidates.length !== countTypes(candidate)) {
29364+
// If there are leftover constituents not directly related, create intersections for any generic constituents that
29365+
// are related by constraint.
2936029366
narrowedType = getUnionType([
2936129367
narrowedType,
2936229368
mapType(candidate, c => {

0 commit comments

Comments
 (0)