diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c2a14e5b9a0..b5526e204ca 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5595,9 +5595,14 @@ namespace ts { if (source.flags & TypeFlags.TypeParameter) { let constraint = getConstraintOfTypeParameter(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)) {