Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions tsc/internal/checker/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -21791,25 +21791,23 @@ func (c *Checker) getPropertyOfUnionOrIntersectionType(t *Type, name string, ski
// these partial properties when identifying discriminant properties, but otherwise they are filtered out
// and do not appear to be present in the union type.
func (c *Checker) getUnionOrIntersectionProperty(t *Type, name string, skipObjectFunctionPropertyAugment bool) *ast.Symbol {
var cache ast.SymbolTable
d := t.AsUnionOrIntersectionType()
cache := &d.propertyCache
if skipObjectFunctionPropertyAugment {
cache = ast.GetSymbolTable(&t.AsUnionOrIntersectionType().propertyCacheWithoutFunctionPropertyAugment)
} else {
cache = ast.GetSymbolTable(&t.AsUnionOrIntersectionType().propertyCache)
cache = &d.propertyCacheWithoutFunctionPropertyAugment
}
if prop := cache[name]; prop != nil {
if prop := (*cache)[name]; prop != nil {
return prop
}
// A property found without the function property augment is also the augmented one unless it is partial.
if !skipObjectFunctionPropertyAugment {
if prop := d.propertyCacheWithoutFunctionPropertyAugment[name]; prop != nil && prop.CheckFlags&ast.CheckFlagsPartial == 0 {
return prop
}
}
prop := c.createUnionOrIntersectionProperty(t, name, skipObjectFunctionPropertyAugment)
if prop != nil {
cache[name] = prop
// Propagate an entry from the non-augmented cache to the augmented cache unless the property is partial.
if skipObjectFunctionPropertyAugment && prop.CheckFlags&ast.CheckFlagsPartial == 0 {
augmentedCache := ast.GetSymbolTable(&t.AsUnionOrIntersectionType().propertyCache)
if augmentedCache[name] == nil {
augmentedCache[name] = prop
}
}
ast.GetSymbolTable(cache)[name] = prop
}
return prop
}
Expand Down