Skip to content

Commit 590fd3f

Browse files
committed
Don't assume that all symbols have declarations
...in Find All References. For example, global `this` doesn't in modules. Part of microsoft#34404
1 parent 1cbbe28 commit 590fd3f

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/services/findAllReferences.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ namespace ts.FindAllReferences.Core {
584584
}
585585

586586
function getReferencedSymbolsForModuleIfDeclaredBySourceFile(symbol: Symbol, program: Program, sourceFiles: readonly SourceFile[], cancellationToken: CancellationToken, options: Options, sourceFilesSet: ReadonlyMap<true>) {
587-
const moduleSourceFile = symbol.flags & SymbolFlags.Module ? find(symbol.declarations, isSourceFile) : undefined;
587+
const moduleSourceFile = (symbol.flags & SymbolFlags.Module) && symbol.declarations && find(symbol.declarations, isSourceFile);
588588
if (!moduleSourceFile) return undefined;
589589
const exportEquals = symbol.exports!.get(InternalSymbolName.ExportEquals);
590590
// If !!exportEquals, we're about to add references to `import("mod")` anyway, so don't double-count them.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/// <reference path='fourslash.ts' />
2+
// @noLib: true
3+
4+
////[|this|];
5+
////export const c = 1;
6+
7+
const [glob] = test.ranges();
8+
verify.referenceGroups(glob, undefined);

0 commit comments

Comments
 (0)