Merge pull request #14131 from Microsoft/release-2.2_default_import_name

Handle undefined import name
This commit is contained in:
Mohamed Hegazy
2017-02-16 16:23:23 -08:00
committed by GitHub
2 changed files with 4 additions and 1 deletions

View File

@@ -154,7 +154,7 @@ namespace ts.FindAllReferences {
const importDecl = importSpecifier.parent as ts.ImportDeclaration;
Debug.assert(importDecl.moduleSpecifier === importSpecifier);
const defaultName = importDecl.importClause.name;
const defaultReferencedSymbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(defaultName));
const defaultReferencedSymbol = defaultName && checker.getAliasedSymbol(checker.getSymbolAtLocation(defaultName));
if (symbol === defaultReferencedSymbol) {
return defaultName.text;
}

View File

@@ -7,5 +7,8 @@
////import [|{| "isWriteAccess": true, "isDefinition": true |}g|] from "./a";
/////*ref*/[|g|]();
// @Filename: c.ts
////import { f } from "./a";
verify.singleReferenceGroup("function f(): void");
verify.goToDefinition("ref", "def");