File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11189,6 +11189,19 @@ namespace ts {
1118911189 return getTypeOfSymbol(thisParameter);
1119011190 }
1119111191 }
11192+ if (isObjectLiteralMethod(func)) {
11193+ // For methods in an object literal, look for a '__this__' property in the contextual
11194+ // type for the object literal. If one exists, remove 'undefined' from the type of that
11195+ // property and report it as the contextual type for 'this' in the method.
11196+ const objectLiteral = <ObjectLiteralExpression>func.parent;
11197+ const type = getApparentTypeOfContextualType(objectLiteral);
11198+ if (type) {
11199+ const propertyType = getTypeOfPropertyOfContextualType(type, "___this__");
11200+ if (propertyType) {
11201+ return getNonNullableType(propertyType);
11202+ }
11203+ }
11204+ }
1119211205 }
1119311206 return undefined;
1119411207 }
You can’t perform that action at this time.
0 commit comments