Exception for 'any' constraint only applies to type parameters

This commit is contained in:
Anders Hejlsberg 2018-05-08 09:42:03 -07:00
parent 5e1330e665
commit ce6fd5eeaa

View file

@ -10740,7 +10740,7 @@ namespace ts {
}
}
const constraint = getConstraintForRelation(<TypeParameter>source);
if (!constraint || constraint.flags & TypeFlags.Any) {
if (!constraint || (source.flags & TypeFlags.TypeParameter && constraint.flags & TypeFlags.Any)) {
// A type variable with no constraint is not related to the non-primitive object type.
if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~TypeFlags.NonPrimitive))) {
errorInfo = saveErrorInfo;