mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 02:33:53 -06:00
findAllRefs: Fix bug for export not at top-level of a module/namespace (#21846)
This commit is contained in:
parent
425a4182a3
commit
49e78f68d2
@ -606,7 +606,9 @@ namespace ts.FindAllReferences {
|
||||
}
|
||||
|
||||
export function getExportInfo(exportSymbol: Symbol, exportKind: ExportKind, checker: TypeChecker): ExportInfo | undefined {
|
||||
const exportingModuleSymbol = checker.getMergedSymbol(exportSymbol.parent); // Need to get merged symbol in case there's an augmentation.
|
||||
const moduleSymbol = exportSymbol.parent;
|
||||
if (!moduleSymbol) return undefined; // This can happen if an `export` is not at the top-level (which is a compile error).
|
||||
const exportingModuleSymbol = checker.getMergedSymbol(moduleSymbol); // Need to get merged symbol in case there's an augmentation.
|
||||
// `export` may appear in a namespace. In that case, just rely on global search.
|
||||
return isExternalModuleSymbol(exportingModuleSymbol) ? { exportingModuleSymbol, exportKind } : undefined;
|
||||
}
|
||||
|
||||
8
tests/cases/fourslash/findAllRefsExportNotAtTopLevel.ts
Normal file
8
tests/cases/fourslash/findAllRefsExportNotAtTopLevel.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
////{
|
||||
//// export const [|{| "isWriteAccess": true, "isDefinition": true |}x|] = 0;
|
||||
//// [|x|];
|
||||
////}
|
||||
|
||||
verify.singleReferenceGroup("const x: 0");
|
||||
Loading…
x
Reference in New Issue
Block a user