@@ -17135,7 +17135,7 @@ namespace ts {
17135
17135
const symbol = getResolvedSymbol(<Identifier>node);
17136
17136
return getExplicitTypeOfSymbol(symbol.flags & SymbolFlags.Alias ? resolveAlias(symbol) : symbol);
17137
17137
case SyntaxKind.ThisKeyword:
17138
- return checkThisExpression (node);
17138
+ return getExplicitThisType (node);
17139
17139
case SyntaxKind.PropertyAccessExpression:
17140
17140
const type = getTypeOfDottedName((<PropertyAccessExpression>node).expression);
17141
17141
const prop = type && getPropertyOfType(type, (<PropertyAccessExpression>node).name.escapedText);
@@ -18720,6 +18720,20 @@ namespace ts {
18720
18720
}
18721
18721
}
18722
18722
18723
+ function getExplicitThisType(node: Expression) {
18724
+ const container = getThisContainer(node, /*includeArrowFunctions*/ false);
18725
+ if (isFunctionLike(container)) {
18726
+ const signature = getSignatureFromDeclaration(container);
18727
+ if (signature.thisParameter) {
18728
+ return getExplicitTypeOfSymbol(signature.thisParameter);
18729
+ }
18730
+ }
18731
+ if (isClassLike(container.parent)) {
18732
+ const symbol = getSymbolOfNode(container.parent);
18733
+ return hasModifier(container, ModifierFlags.Static) ? getTypeOfSymbol(symbol) : (getDeclaredTypeOfSymbol(symbol) as InterfaceType).thisType!;
18734
+ }
18735
+ }
18736
+
18723
18737
function getClassNameFromPrototypeMethod(container: Node) {
18724
18738
// Check if it's the RHS of a x.prototype.y = function [name]() { .... }
18725
18739
if (container.kind === SyntaxKind.FunctionExpression &&
0 commit comments