Skip to content

Commit 65790d1

Browse files
committed
Check assignability recursively when source is type parameter with union constraint
1 parent 05480e3 commit 65790d1

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/compiler/checker.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4067,10 +4067,17 @@ module ts {
40674067
let reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo;
40684068
// identity relation does not use apparent type
40694069
let sourceOrApparentType = relation === identityRelation ? source : getApparentType(source);
4070-
if (sourceOrApparentType.flags & TypeFlags.ObjectType && target.flags & TypeFlags.ObjectType &&
4071-
(result = objectTypeRelatedTo(sourceOrApparentType, <ObjectType>target, reportStructuralErrors))) {
4072-
errorInfo = saveErrorInfo;
4073-
return result;
4070+
if (sourceOrApparentType.flags & TypeFlags.ObjectType && target.flags & TypeFlags.ObjectType) {
4071+
if (result = objectTypeRelatedTo(sourceOrApparentType, <ObjectType>target, reportStructuralErrors)) {
4072+
errorInfo = saveErrorInfo;
4073+
return result;
4074+
}
4075+
}
4076+
else if (source.flags & TypeFlags.TypeParameter && sourceOrApparentType.flags & TypeFlags.Union) {
4077+
if (result = isRelatedTo(sourceOrApparentType, <ObjectType>target, reportStructuralErrors)) {
4078+
errorInfo = saveErrorInfo;
4079+
return result;
4080+
}
40744081
}
40754082
}
40764083
if (reportErrors) {

0 commit comments

Comments
 (0)