Skip to content

Commit a252ef9

Browse files
committed
Create separate cache when skipping function and object property augmentation
1 parent fd9c2ea commit a252ef9

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/compiler/checker.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10997,12 +10997,13 @@ namespace ts {
1099710997
// these partial properties when identifying discriminant properties, but otherwise they are filtered out
1099810998
// and do not appear to be present in the union type.
1099910999
function getUnionOrIntersectionProperty(type: UnionOrIntersectionType, name: __String, skipObjectFunctionPropertyAugment?: boolean): Symbol | undefined {
11000-
const properties = type.propertyCache || (type.propertyCache = createSymbolTable());
11000+
const properties = skipObjectFunctionPropertyAugment ?
11001+
type.propertyCacheWithoutObjectFunctionPropertyAugment ||= createSymbolTable() :
11002+
type.propertyCache ||= createSymbolTable();
1100111003
let property = properties.get(name);
1100211004
if (!property) {
1100311005
property = createUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment);
11004-
// Dont set the result since it might not be correct if skipping lookup from property of Object and function type
11005-
if (property && !skipObjectFunctionPropertyAugment) {
11006+
if (property) {
1100611007
properties.set(name, property);
1100711008
}
1100811009
}

src/compiler/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5140,7 +5140,9 @@ namespace ts {
51405140
/* @internal */
51415141
objectFlags: ObjectFlags;
51425142
/* @internal */
5143-
propertyCache: SymbolTable; // Cache of resolved properties
5143+
propertyCache?: SymbolTable; // Cache of resolved properties
5144+
/* @internal */
5145+
propertyCacheWithoutObjectFunctionPropertyAugment?: SymbolTable; // Cache of resolved properties that does not augment function or object type properties
51445146
/* @internal */
51455147
resolvedProperties: Symbol[];
51465148
/* @internal */

0 commit comments

Comments
 (0)