Merge pull request #6952 from tinganho/goToNamedImport

Go to defininition should not go to named import
This commit is contained in:
Mohamed Hegazy 2016-02-08 19:51:28 -08:00
commit 4bf104349d
2 changed files with 11 additions and 2 deletions

View File

@ -4639,7 +4639,16 @@ namespace ts {
// to jump to the implementation directly.
if (symbol.flags & SymbolFlags.Alias) {
const declaration = symbol.declarations[0];
if (node.kind === SyntaxKind.Identifier && node.parent === declaration) {
// Go to the original declaration for cases:
//
// (1) when the aliased symbol was declared in the location(parent).
// (2) when the aliased symbol is originating from a named import.
//
if (node.kind === SyntaxKind.Identifier &&
(node.parent === declaration ||
(declaration.kind === SyntaxKind.ImportSpecifier && declaration.parent && declaration.parent.kind === SyntaxKind.NamedImports))) {
symbol = typeChecker.getAliasedSymbol(symbol);
}
}

View File

@ -31,7 +31,7 @@ goTo.file("e.ts");
goTo.marker('classReference');
goTo.definition();
verify.caretAtMarker('classAliasDefinition');
verify.caretAtMarker('classDefinition');
goTo.marker('classAliasDefinition');
goTo.definition();