Check this expressions in object literal methods

Add a test and baseline
This commit is contained in:
Nathan Shively-Sanders
2016-03-09 13:06:06 -08:00
parent 482acccada
commit 7b531fcd05
5 changed files with 70 additions and 0 deletions

View File

@@ -7494,6 +7494,14 @@ namespace ts {
const symbol = getSymbolOfNode(container.parent);
return container.flags & NodeFlags.Static ? getTypeOfSymbol(symbol) : (<InterfaceType>getDeclaredTypeOfSymbol(symbol)).thisType;
}
if (container.parent && container.parent.kind === SyntaxKind.ObjectLiteralExpression) {
// Note: this works because object literal methods are deferred,
// which means that the type of the containing object literal is already known.
const type = checkExpressionCached(<ObjectLiteralExpression>container.parent);
if (type) {
return type;
}
}
if (isInJavaScriptFile(node)) {
const type = getTypeForThisExpressionFromJSDoc(container);