Skip to content

Commit

Permalink
Merge pull request #34659 from amcasey/FARGlobalThis
Browse files Browse the repository at this point in the history
Don't assume that all symbols have declarations
  • Loading branch information
amcasey authored Oct 22, 2019
2 parents 479d306 + 590fd3f commit 6f04f52
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/services/findAllReferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ namespace ts.FindAllReferences.Core {
}

function getReferencedSymbolsForModuleIfDeclaredBySourceFile(symbol: Symbol, program: Program, sourceFiles: readonly SourceFile[], cancellationToken: CancellationToken, options: Options, sourceFilesSet: ReadonlyMap<true>) {
const moduleSourceFile = symbol.flags & SymbolFlags.Module ? find(symbol.declarations, isSourceFile) : undefined;
const moduleSourceFile = (symbol.flags & SymbolFlags.Module) && symbol.declarations && find(symbol.declarations, isSourceFile);
if (!moduleSourceFile) return undefined;
const exportEquals = symbol.exports!.get(InternalSymbolName.ExportEquals);
// If !!exportEquals, we're about to add references to `import("mod")` anyway, so don't double-count them.
Expand Down
8 changes: 8 additions & 0 deletions tests/cases/fourslash/findAllRefsGlobalThisKeywordInModule.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/// <reference path='fourslash.ts' />
// @noLib: true

////[|this|];
////export const c = 1;

const [glob] = test.ranges();
verify.referenceGroups(glob, undefined);

0 comments on commit 6f04f52

Please sign in to comment.