mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Don't assume that all symbols have declarations
...in Find All References. For example, global `this` doesn't in modules. Part of #34404
This commit is contained in:
parent
1cbbe288ac
commit
590fd3f2a2
@ -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.
|
||||
|
||||
@ -0,0 +1,8 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
// @noLib: true
|
||||
|
||||
////[|this|];
|
||||
////export const c = 1;
|
||||
|
||||
const [glob] = test.ranges();
|
||||
verify.referenceGroups(glob, undefined);
|
||||
Loading…
x
Reference in New Issue
Block a user