From cdd10b09b19797647cffe0996bd3dc846a14b6aa Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Sun, 28 Feb 2016 20:08:55 -0800 Subject: [PATCH] Instantiate type parameters with themselves as their 'this' type when relating. --- src/compiler/checker.ts | 5 +++++ 1 file changed, 5 insertions(+) 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)) {