Skip to content

Commit b5cde15

Browse files
committed
Updated logic for high-order type relationships
1 parent ebaa253 commit b5cde15

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

src/compiler/checker.ts

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9226,20 +9226,13 @@ namespace ts {
92269226
}
92279227
}
92289228
}
9229-
else if (target.flags & TypeFlags.Promised) {
9230-
// A promised S is related to a promised T if S is related to T
9231-
if (source.flags & TypeFlags.Promised) {
9232-
if (result = isRelatedTo((<PromisedType>source).type, (<PromisedType>target).type, /*reportErrors*/ false)) {
9233-
return result;
9234-
}
9235-
}
9236-
// A type S is related to promised T if S is related to promised C, where C is the
9237-
// constraint of T.
9238-
const constraint = getConstraintOfType((<PromisedType>target).type);
9239-
if (constraint) {
9240-
if (result = isRelatedTo(source, getPromisedType(constraint), reportErrors)) {
9241-
return result;
9242-
}
9229+
else if (target.flags & TypeFlags.Promised && source.flags & TypeFlags.Promised) {
9230+
// A promised S is related to a promised T if S is related to T:
9231+
//
9232+
// S <: T ⇒ promised S <: promised T
9233+
//
9234+
if (result = isRelatedTo((<PromisedType>source).type, (<PromisedType>target).type, reportErrors)) {
9235+
return result;
92439236
}
92449237
}
92459238

@@ -9291,7 +9284,10 @@ namespace ts {
92919284
}
92929285
else if (source.flags & TypeFlags.Promised) {
92939286
// A promised S is related to T if promised C is related to T, where C is the
9294-
// constraint of S.
9287+
// constraint of S:
9288+
//
9289+
// S <: C ^ promised C <: T ⇒ promised S <: T
9290+
//
92959291
const constraint = getConstraintOfType((<PromisedType>source).type);
92969292
if (constraint) {
92979293
if (result = isRelatedTo(getPromisedType(constraint), target, reportErrors)) {

0 commit comments

Comments
 (0)