findAllRefs: Fix bug for export not at top-level of a module/namespace (#21846)

This commit is contained in:
Andy 2018-02-09 15:10:34 -08:00 committed by GitHub
parent 425a4182a3
commit 49e78f68d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -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;
}

View File

@ -0,0 +1,8 @@
/// <reference path="fourslash.ts" />
////{
//// export const [|{| "isWriteAccess": true, "isDefinition": true |}x|] = 0;
//// [|x|];
////}
verify.singleReferenceGroup("const x: 0");