Contextual signatures without thisType return anyType

If a contextual signature is found, if its thisType is undefined, then the contextual type of `this` is now `any`.
Previously `checkThisExpression` would keep looking for a different type for `this`.

Also update tests to show this new behaviour.
This commit is contained in:
Nathan Shively-Sanders
2016-04-28 14:17:11 -07:00
parent 88854d2c0f
commit 9f7621c7e2
5 changed files with 332 additions and 118 deletions

View File

@@ -8453,7 +8453,7 @@ namespace ts {
if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== SyntaxKind.ArrowFunction) {
const contextualSignature = getContextualSignature(func);
if (contextualSignature) {
return contextualSignature.thisType;
return contextualSignature.thisType || anyType;
}
else if (getContextualTypeForFunctionLikeDeclaration(func) === anyType) {
return anyType;