Skip to content

Commit 7eda73a

Browse files
committed
Remove the TypeChecked node flag
Its last use was in reportNonexistentProperty, which kept both a set of (name, containing type, JS) keys and the flag on the name's node. The flag already stopped a second report for the node on any containing type, so the keyed set never caught anything the flag did not. Keep a single set of reported name nodes instead. Reports only run while checking, so this stays checking-only state, as the keyed set was.
1 parent e2138e8 commit 7eda73a

3 files changed

Lines changed: 6 additions & 19 deletions

File tree

‎tsc/internal/checker/checker.go‎

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -263,14 +263,6 @@ type PropertiesTypesKey struct {
263263
includeOrigin bool
264264
}
265265

266-
// NonExistentPropertyKey
267-
268-
type NonExistentPropertyKey struct {
269-
propNode *ast.Node
270-
containingType *Type
271-
isUncheckedJS bool
272-
}
273-
274266
// FlowLoopKey
275267

276268
type FlowLoopKey struct {
@@ -1025,7 +1017,7 @@ type memoStore struct {
10251017
ambientModules []*ast.Symbol
10261018
reportedUnreachableNodes memoSet[*ast.Node]
10271019
checkedRegularExpressions memoSet[*ast.Node]
1028-
nonExistentProperties collections.Set[NonExistentPropertyKey]
1020+
nonExistentPropertyNodes collections.Set[*ast.Node] // Property names reported as nonexistent
10291021
deferredDiagnosticCallbacks []func(c *Checker)
10301022
memoStates map[memoKey]*memoState // Memo state of results computed by queries; see memo.go
10311023
stateFilter []uint64 // Memo keys that may have a memo state; see memoState
@@ -12141,16 +12133,12 @@ func (c *Checker) reportNonexistentProperty(propNode *ast.Node, containingType *
1214112133
c.recordEffect(func(c *Checker) { c.reportNonexistentProperty(propNode, containingType, isUncheckedJS) })
1214212134
return
1214312135
}
12144-
key := NonExistentPropertyKey{propNode, containingType, isUncheckedJS}
12145-
if c.nonExistentProperties.Has(key) {
12136+
// Only the first report for a name is made, even if it is reported again
12137+
// on another containing type.
12138+
if c.nonExistentPropertyNodes.Has(propNode) {
1214612139
return
1214712140
}
12148-
c.nonExistentProperties.Add(key)
12149-
links := c.nodeLinks.Get(propNode)
12150-
if links.flags&NodeCheckFlagsTypeChecked != 0 {
12151-
return // error already made/in progress
12152-
}
12153-
links.flags |= NodeCheckFlagsTypeChecked
12141+
c.nonExistentPropertyNodes.Add(propNode)
1215412142
if ast.IsJSDocNameReferenceContext(propNode) {
1215512143
return
1215612144
}

‎tsc/internal/checker/checker_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ var unmemoizedCacheFields = map[string]string{
592592
"memoStore.mu": unmemoizedMemoState,
593593
"memoStore.diagnostics": unmemoizedChecking,
594594
"memoStore.suggestionDiagnostics": unmemoizedChecking,
595-
"memoStore.nonExistentProperties": unmemoizedChecking,
595+
"memoStore.nonExistentPropertyNodes": unmemoizedChecking,
596596
"memoStore.deferredDiagnosticCallbacks": unmemoizedChecking,
597597
"SymbolReferenceLinks.referenceKinds": unmemoizedChecking,
598598
"AliasSymbolLinks.referenced": unmemoizedMark,

‎tsc/internal/checker/types.go‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,6 @@ type NodeCheckFlags uint32
415415

416416
const (
417417
NodeCheckFlagsNone NodeCheckFlags = 0
418-
NodeCheckFlagsTypeChecked NodeCheckFlags = 1 << 0 // Node has been type checked
419418
NodeCheckFlagsContextChecked NodeCheckFlags = 1 << 6 // Contextual types have been assigned
420419
NodeCheckFlagsSignatureContextChecked NodeCheckFlags = 1 << 7 // Signature of a contextually typed function has been checked
421420
NodeCheckFlagsEnumValuesComputed NodeCheckFlags = 1 << 10 // Values for enum members have been computed, and any errors have been reported for them.

0 commit comments

Comments
 (0)