Skip to content
Open
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
15 changes: 13 additions & 2 deletions tsc/internal/checker/flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -1610,8 +1610,19 @@ func (c *Checker) isMatchingReference(source *ast.Node, target *ast.Node) bool {
if ast.IsThisInTypeQuery(source) {
return target.Kind == ast.KindThisKeyword
}
return ast.IsIdentifier(target) && c.getResolvedSymbol(source) == c.getResolvedSymbol(target) ||
(ast.IsVariableDeclaration(target) || ast.IsBindingElement(target)) && c.getExportSymbolOfValueSymbolIfExported(c.getResolvedSymbol(source)) == c.getSymbolOfDeclaration(target)
if ast.IsIdentifier(target) {
return c.getResolvedSymbol(source) == c.getResolvedSymbol(target)
}
if ast.IsVariableDeclaration(target) || ast.IsBindingElement(target) {
// A declaration's symbol is named by its identifier, so a reference with a
// different name cannot resolve to it. Checking names first avoids loading
// the symbols of every unrelated declaration seen while walking flow nodes.
if name := target.Name(); name != nil && ast.IsIdentifier(name) && name.AsIdentifier().Text != source.Text() {
return false
}
return c.getExportSymbolOfValueSymbolIfExported(c.getResolvedSymbol(source)) == c.getSymbolOfDeclaration(target)
}
return false
case ast.KindThisKeyword:
return target.Kind == ast.KindThisKeyword
case ast.KindSuperKeyword:
Expand Down
Loading