Instantiate type parameters with themselves as their 'this' type when relating.

This commit is contained in:
Daniel Rosenwasser
2016-02-28 20:08:55 -08:00
parent daf15963a3
commit cdd10b09b1
+5
View File
@@ -5595,9 +5595,14 @@ namespace ts {
if (source.flags & TypeFlags.TypeParameter) {
let constraint = getConstraintOfTypeParameter(<TypeParameter>source);
if (!constraint || constraint.flags & TypeFlags.Any) {
constraint = emptyObjectType;
}
// The constraint may need to be further instantiated with its 'this' type.
constraint = getTypeWithThisArgument(constraint);
// Report constraint errors only if the constraint is not the empty object type
const reportConstraintErrors = reportErrors && constraint !== emptyObjectType;
if (result = isRelatedTo(constraint, target, reportConstraintErrors)) {