@@ -2522,7 +2522,7 @@ namespace ts {
2522
2522
let symbolFromVariable: Symbol | undefined;
2523
2523
// First check if module was specified with "export=". If so, get the member from the resolved type
2524
2524
if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get(InternalSymbolName.ExportEquals)) {
2525
- symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name.escapedText);
2525
+ symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name.escapedText, /*skipObjectFunctionPropertyAugment*/ true );
2526
2526
}
2527
2527
else {
2528
2528
symbolFromVariable = getPropertyOfVariable(targetSymbol, name.escapedText);
@@ -10367,7 +10367,7 @@ namespace ts {
10367
10367
t;
10368
10368
}
10369
10369
10370
- function createUnionOrIntersectionProperty(containingType: UnionOrIntersectionType, name: __String): Symbol | undefined {
10370
+ function createUnionOrIntersectionProperty(containingType: UnionOrIntersectionType, name: __String, skipObjectFunctionPropertyAugment?: boolean ): Symbol | undefined {
10371
10371
const propSet = createMap<Symbol>();
10372
10372
let indexTypes: Type[] | undefined;
10373
10373
const isUnion = containingType.flags & TypeFlags.Union;
@@ -10379,7 +10379,7 @@ namespace ts {
10379
10379
for (const current of containingType.types) {
10380
10380
const type = getApparentType(current);
10381
10381
if (!(type === errorType || type.flags & TypeFlags.Never)) {
10382
- const prop = getPropertyOfType(type, name);
10382
+ const prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment );
10383
10383
const modifiers = prop ? getDeclarationModifierFlagsFromSymbol(prop) : 0;
10384
10384
if (prop && !(modifiers & excludeModifiers)) {
10385
10385
if (isUnion) {
@@ -10485,20 +10485,21 @@ namespace ts {
10485
10485
// constituents, in which case the isPartial flag is set when the containing type is union type. We need
10486
10486
// these partial properties when identifying discriminant properties, but otherwise they are filtered out
10487
10487
// and do not appear to be present in the union type.
10488
- function getUnionOrIntersectionProperty(type: UnionOrIntersectionType, name: __String): Symbol | undefined {
10488
+ function getUnionOrIntersectionProperty(type: UnionOrIntersectionType, name: __String, skipObjectFunctionPropertyAugment?: boolean ): Symbol | undefined {
10489
10489
const properties = type.propertyCache || (type.propertyCache = createSymbolTable());
10490
10490
let property = properties.get(name);
10491
10491
if (!property) {
10492
- property = createUnionOrIntersectionProperty(type, name);
10493
- if (property) {
10492
+ property = createUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment);
10493
+ // Dont set the result since it might not be correct if skipping lookup from property of Object and function type
10494
+ if (property && !skipObjectFunctionPropertyAugment) {
10494
10495
properties.set(name, property);
10495
10496
}
10496
10497
}
10497
10498
return property;
10498
10499
}
10499
10500
10500
- function getPropertyOfUnionOrIntersectionType(type: UnionOrIntersectionType, name: __String): Symbol | undefined {
10501
- const property = getUnionOrIntersectionProperty(type, name);
10501
+ function getPropertyOfUnionOrIntersectionType(type: UnionOrIntersectionType, name: __String, skipObjectFunctionPropertyAugment?: boolean ): Symbol | undefined {
10502
+ const property = getUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment );
10502
10503
// We need to filter out partial properties in union types
10503
10504
return property && !(getCheckFlags(property) & CheckFlags.ReadPartial) ? property : undefined;
10504
10505
}
@@ -10576,14 +10577,15 @@ namespace ts {
10576
10577
* @param type a type to look up property from
10577
10578
* @param name a name of property to look up in a given type
10578
10579
*/
10579
- function getPropertyOfType(type: Type, name: __String): Symbol | undefined {
10580
+ function getPropertyOfType(type: Type, name: __String, skipObjectFunctionPropertyAugment?: boolean ): Symbol | undefined {
10580
10581
type = getApparentType(getReducedType(type));
10581
10582
if (type.flags & TypeFlags.Object) {
10582
10583
const resolved = resolveStructuredTypeMembers(<ObjectType>type);
10583
10584
const symbol = resolved.members.get(name);
10584
10585
if (symbol && symbolIsValue(symbol)) {
10585
10586
return symbol;
10586
10587
}
10588
+ if (skipObjectFunctionPropertyAugment) return undefined;
10587
10589
const functionType = resolved === anyFunctionType ? globalFunctionType :
10588
10590
resolved.callSignatures.length ? globalCallableFunctionType :
10589
10591
resolved.constructSignatures.length ? globalNewableFunctionType :
@@ -10597,7 +10599,7 @@ namespace ts {
10597
10599
return getPropertyOfObjectType(globalObjectType, name);
10598
10600
}
10599
10601
if (type.flags & TypeFlags.UnionOrIntersection) {
10600
- return getPropertyOfUnionOrIntersectionType(<UnionOrIntersectionType>type, name);
10602
+ return getPropertyOfUnionOrIntersectionType(<UnionOrIntersectionType>type, name, skipObjectFunctionPropertyAugment );
10601
10603
}
10602
10604
return undefined;
10603
10605
}
0 commit comments