From 2ca6164fea89ca344b04ee775a472564ae836511 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 16 Feb 2017 17:04:30 -0800 Subject: [PATCH] Default contextual 'this' type is containing object literal --- src/compiler/checker.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 898b7b4d539..3949a65eea8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11230,6 +11230,9 @@ namespace ts { } objectLiteral = objectLiteral.parent.parent; } + // There was no contextual ThisType for the containing object literal, so the contextual type + // for 'this' is the type of the object literal itself. + return checkExpressionCached(containingLiteral); } } return undefined;