mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-11 20:37:46 -05:00
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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user