From b5cde15672565b8bbb35e233461eaf92932d1010 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 7 Aug 2017 16:35:12 -0700 Subject: [PATCH] Updated logic for high-order type relationships --- src/compiler/checker.ts | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2e6458ad46f..790a69364b6 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9226,20 +9226,13 @@ namespace ts { } } } - else if (target.flags & TypeFlags.Promised) { - // A promised S is related to a promised T if S is related to T - if (source.flags & TypeFlags.Promised) { - if (result = isRelatedTo((source).type, (target).type, /*reportErrors*/ false)) { - return result; - } - } - // A type S is related to promised T if S is related to promised C, where C is the - // constraint of T. - const constraint = getConstraintOfType((target).type); - if (constraint) { - if (result = isRelatedTo(source, getPromisedType(constraint), reportErrors)) { - return result; - } + else if (target.flags & TypeFlags.Promised && source.flags & TypeFlags.Promised) { + // A promised S is related to a promised T if S is related to T: + // + // S <: T ⇒ promised S <: promised T + // + if (result = isRelatedTo((source).type, (target).type, reportErrors)) { + return result; } } @@ -9291,7 +9284,10 @@ namespace ts { } else if (source.flags & TypeFlags.Promised) { // A promised S is related to T if promised C is related to T, where C is the - // constraint of S. + // constraint of S: + // + // S <: C ^ promised C <: T ⇒ promised S <: T + // const constraint = getConstraintOfType((source).type); if (constraint) { if (result = isRelatedTo(getPromisedType(constraint), target, reportErrors)) {