Merge pull request #8389 from Microsoft/make-object-literal-this-any-typed

Make `this` in object literal always of type `any`
This commit is contained in:
Nathan Shively-Sanders
2016-04-29 19:15:04 -07:00
33 changed files with 156 additions and 206 deletions

View File

@@ -8228,15 +8228,6 @@ namespace ts {
if (signature.thisType) {
return signature.thisType;
}
const parentObject = container.parent && container.parent.kind === SyntaxKind.PropertyAssignment ? container.parent.parent : container.parent;
if (parentObject && parentObject.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>parentObject);
if (type) {
return type;
}
}
}
if (isClassLike(container.parent)) {
const symbol = getSymbolOfNode(container.parent);
@@ -8476,10 +8467,7 @@ namespace ts {
if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== SyntaxKind.ArrowFunction) {
const contextualSignature = getContextualSignature(func);
if (contextualSignature) {
return contextualSignature.thisType || anyType;
}
else if (getContextualTypeForFunctionLikeDeclaration(func) === anyType) {
return anyType;
return contextualSignature.thisType;
}
}