From a9055b872908ef4e0e0adf2ca46d373f87a1593b Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Thu, 30 Apr 2015 15:27:58 -0700 Subject: [PATCH] Fix contextual typing of object literal methods --- src/compiler/checker.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 95c187b7bc0..be9047326ca 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5952,8 +5952,10 @@ module ts { } function getContextualSignatureForFunctionLikeDeclaration(node: FunctionLikeDeclaration): Signature { - // Only function expressions and arrow functions are contextually typed. - return isFunctionExpressionOrArrowFunction(node) ? getContextualSignature(node) : undefined; + // Only function expressions, arrow functions, and object literal methods are contextually typed. + return isFunctionExpressionOrArrowFunction(node) || isObjectLiteralMethod(node) + ? getContextualSignature(node) + : undefined; } // Return the contextual signature for a given expression node. A contextual type provides a