From 65790d16637a7a83146b5b07ea95672dc77052e6 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Tue, 14 Apr 2015 17:48:56 -0700 Subject: [PATCH] Check assignability recursively when source is type parameter with union constraint --- src/compiler/checker.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e9430a058f8..1b5bf8a6541 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4067,10 +4067,17 @@ module ts { let reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; // identity relation does not use apparent type let sourceOrApparentType = relation === identityRelation ? source : getApparentType(source); - if (sourceOrApparentType.flags & TypeFlags.ObjectType && target.flags & TypeFlags.ObjectType && - (result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors))) { - errorInfo = saveErrorInfo; - return result; + if (sourceOrApparentType.flags & TypeFlags.ObjectType && target.flags & TypeFlags.ObjectType) { + if (result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors)) { + errorInfo = saveErrorInfo; + return result; + } + } + else if (source.flags & TypeFlags.TypeParameter && sourceOrApparentType.flags & TypeFlags.Union) { + if (result = isRelatedTo(sourceOrApparentType, target, reportStructuralErrors)) { + errorInfo = saveErrorInfo; + return result; + } } } if (reportErrors) {