@@ -700,19 +700,21 @@ namespace ts.FindAllReferences {
700
700
}
701
701
} ) ;
702
702
703
- for ( const decl of symbol . declarations ) {
704
- switch ( decl . kind ) {
705
- case SyntaxKind . SourceFile :
706
- // Don't include the source file itself. (This may not be ideal behavior, but awkward to include an entire file as a reference.)
707
- break ;
708
- case SyntaxKind . ModuleDeclaration :
709
- if ( sourceFilesSet . has ( decl . getSourceFile ( ) . fileName ) ) {
710
- references . push ( nodeEntry ( ( decl as ModuleDeclaration ) . name ) ) ;
711
- }
712
- break ;
713
- default :
714
- // This may be merged with something.
715
- Debug . assert ( ! ! ( symbol . flags & SymbolFlags . Transient ) , "Expected a module symbol to be declared by a SourceFile or ModuleDeclaration." ) ;
703
+ if ( symbol . declarations ) {
704
+ for ( const decl of symbol . declarations ) {
705
+ switch ( decl . kind ) {
706
+ case SyntaxKind . SourceFile :
707
+ // Don't include the source file itself. (This may not be ideal behavior, but awkward to include an entire file as a reference.)
708
+ break ;
709
+ case SyntaxKind . ModuleDeclaration :
710
+ if ( sourceFilesSet . has ( decl . getSourceFile ( ) . fileName ) ) {
711
+ references . push ( nodeEntry ( ( decl as ModuleDeclaration ) . name ) ) ;
712
+ }
713
+ break ;
714
+ default :
715
+ // This may be merged with something.
716
+ Debug . assert ( ! ! ( symbol . flags & SymbolFlags . Transient ) , "Expected a module symbol to be declared by a SourceFile or ModuleDeclaration." ) ;
717
+ }
716
718
}
717
719
}
718
720
@@ -1075,6 +1077,8 @@ namespace ts.FindAllReferences {
1075
1077
1076
1078
// Go to the symbol we imported from and find references for it.
1077
1079
function searchForImportedSymbol ( symbol : Symbol , state : State ) : void {
1080
+ if ( ! symbol . declarations ) return ;
1081
+
1078
1082
for ( const declaration of symbol . declarations ) {
1079
1083
const exportingFile = declaration . getSourceFile ( ) ;
1080
1084
// Need to search in the file even if it's not in the search-file set, because it might export the symbol.
@@ -1554,7 +1558,7 @@ namespace ts.FindAllReferences {
1554
1558
*/
1555
1559
function findOwnConstructorReferences ( classSymbol : Symbol , sourceFile : SourceFile , addNode : ( node : Node ) => void ) : void {
1556
1560
const constructorSymbol = getClassConstructorSymbol ( classSymbol ) ;
1557
- if ( constructorSymbol ) {
1561
+ if ( constructorSymbol && constructorSymbol . declarations ) {
1558
1562
for ( const decl of constructorSymbol . declarations ) {
1559
1563
const ctrKeyword = findChildOfKind ( decl , SyntaxKind . ConstructorKeyword , sourceFile ) ! ;
1560
1564
Debug . assert ( decl . kind === SyntaxKind . Constructor && ! ! ctrKeyword ) ;
@@ -1586,7 +1590,7 @@ namespace ts.FindAllReferences {
1586
1590
/** Find references to `super` in the constructor of an extending class. */
1587
1591
function findSuperConstructorAccesses ( classDeclaration : ClassLikeDeclaration , addNode : ( node : Node ) => void ) : void {
1588
1592
const constructor = getClassConstructorSymbol ( classDeclaration . symbol ) ;
1589
- if ( ! constructor ) {
1593
+ if ( ! ( constructor && constructor . declarations ) ) {
1590
1594
return ;
1591
1595
}
1592
1596
@@ -1722,7 +1726,7 @@ namespace ts.FindAllReferences {
1722
1726
// Set the key so that we don't infinitely recurse
1723
1727
cachedResults . set ( key , false ) ;
1724
1728
1725
- const inherits = symbol . declarations . some ( declaration =>
1729
+ const inherits = ! ! symbol . declarations && symbol . declarations . some ( declaration =>
1726
1730
getAllSuperTypeNodes ( declaration ) . some ( typeReference => {
1727
1731
const type = checker . getTypeAtLocation ( typeReference ) ;
1728
1732
return ! ! type && ! ! type . symbol && explicitlyInheritsFrom ( type . symbol , parent , cachedResults , checker ) ;
0 commit comments