findAllReferences: Don't fail on broken re-export (#21841)

This commit is contained in:
Andy
2018-02-09 13:56:04 -08:00
committed by GitHub
parent aa1ebda6a6
commit 31ec5e7390
3 changed files with 15 additions and 2 deletions
+3 -2
View File
@@ -914,7 +914,8 @@ namespace ts.FindAllReferences.Core {
// At `export { x } from "foo"`, also search for the imported symbol `"foo".x`.
if (search.comingFrom !== ImportExport.Export && exportDeclaration.moduleSpecifier && !propertyName) {
searchForImportedSymbol(state.checker.getExportSpecifierLocalTargetSymbol(exportSpecifier), state);
const imported = state.checker.getExportSpecifierLocalTargetSymbol(exportSpecifier);
if (imported) searchForImportedSymbol(imported, state);
}
function addRef() {
@@ -923,7 +924,7 @@ namespace ts.FindAllReferences.Core {
}
function getLocalSymbolForExportSpecifier(referenceLocation: Identifier, referenceSymbol: Symbol, exportSpecifier: ExportSpecifier, checker: TypeChecker): Symbol {
return isExportSpecifierAlias(referenceLocation, exportSpecifier) ? checker.getExportSpecifierLocalTargetSymbol(exportSpecifier) : referenceSymbol;
return isExportSpecifierAlias(referenceLocation, exportSpecifier) && checker.getExportSpecifierLocalTargetSymbol(exportSpecifier) || referenceSymbol;
}
function isExportSpecifierAlias(referenceLocation: Identifier, exportSpecifier: ExportSpecifier): boolean {
@@ -0,0 +1,6 @@
/// <reference path='fourslash.ts' />
// @Filename: /a.ts
////export { [|{| "isWriteAccess": true, "isDefinition": true |}x|] };
verify.singleReferenceGroup("import x");
@@ -0,0 +1,6 @@
/// <reference path='fourslash.ts' />
// @Filename: /a.ts
////export { [|{| "isWriteAccess": true, "isDefinition": true |}x|] } from "nonsense";
verify.singleReferenceGroup("import x");