@@ -19099,10 +19099,13 @@ namespace ts {
19099
19099
19100
19100
// Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily
19101
19101
// be "pushed" onto a node using the contextualType property.
19102
- function getApparentTypeOfContextualType(node: Expression, contextFlags?: ContextFlags): Type | undefined {
19103
- const contextualType = instantiateContextualType(getContextualType(node, contextFlags), node, contextFlags);
19104
- if (contextualType) {
19105
- const apparentType = mapType(contextualType, getApparentType, /*noReductions*/ true);
19102
+ function getApparentTypeOfContextualType(node: Expression | MethodDeclaration, contextFlags?: ContextFlags): Type | undefined {
19103
+ const contextualType = isObjectLiteralMethod(node) ?
19104
+ getContextualTypeForObjectLiteralMethod(node, contextFlags) :
19105
+ getContextualType(node, contextFlags);
19106
+ const instantiatedType = instantiateContextualType(contextualType, node, contextFlags);
19107
+ if (instantiatedType) {
19108
+ const apparentType = mapType(instantiatedType, getApparentType, /*noReductions*/ true);
19106
19109
if (apparentType.flags & TypeFlags.Union) {
19107
19110
if (isObjectLiteralExpression(node)) {
19108
19111
return discriminateContextualTypeByObjectMembers(node, apparentType as UnionType);
@@ -19426,9 +19429,7 @@ namespace ts {
19426
19429
if (typeTagSignature) {
19427
19430
return typeTagSignature;
19428
19431
}
19429
- const type = isObjectLiteralMethod(node) ?
19430
- getContextualTypeForObjectLiteralMethod(node, ContextFlags.Signature) :
19431
- getApparentTypeOfContextualType(node, ContextFlags.Signature);
19432
+ const type = getApparentTypeOfContextualType(node, ContextFlags.Signature);
19432
19433
if (!type) {
19433
19434
return undefined;
19434
19435
}
0 commit comments