From 6b303271f08c78474c4b7838b6288d85fe404ade Mon Sep 17 00:00:00 2001 From: Tingan Ho Date: Sun, 7 Feb 2016 19:54:38 +0800 Subject: [PATCH 1/3] Go to defininition should not go to named import --- src/services/services.ts | 8 +++++++- tests/cases/fourslash/goToDefinitionImportedNames3.ts | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 6761c487c6c..d291078f7b8 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4639,7 +4639,13 @@ 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) { + + // We want go to the original declaration if the aliased symbol was declared in the location's parent node. + // Except for cases 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); } } diff --git a/tests/cases/fourslash/goToDefinitionImportedNames3.ts b/tests/cases/fourslash/goToDefinitionImportedNames3.ts index d55137575ef..70fce1749e4 100644 --- a/tests/cases/fourslash/goToDefinitionImportedNames3.ts +++ b/tests/cases/fourslash/goToDefinitionImportedNames3.ts @@ -31,7 +31,7 @@ goTo.file("e.ts"); goTo.marker('classReference'); goTo.definition(); -verify.caretAtMarker('classAliasDefinition'); +verify.caretAtMarker('classDefinition'); goTo.marker('classAliasDefinition'); goTo.definition(); From 3d8a472527e4f0809c75df42a28d03731dadab35 Mon Sep 17 00:00:00 2001 From: Tingan Ho Date: Sun, 7 Feb 2016 20:09:14 +0800 Subject: [PATCH 2/3] Updated comment --- src/services/services.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index d291078f7b8..7493e894d1c 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4640,8 +4640,11 @@ namespace ts { if (symbol.flags & SymbolFlags.Alias) { const declaration = symbol.declarations[0]; - // We want go to the original declaration if the aliased symbol was declared in the location's parent node. - // Except for cases when the aliased symbol is originating from a named import. + // Go to the original declaration for cases: + // + // (1) when the aliased symbol was declared in 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))) { From 43d2054eaca403fb2eebd5fe784b925e75f5d7c6 Mon Sep 17 00:00:00 2001 From: Tingan Ho Date: Sun, 7 Feb 2016 20:10:59 +0800 Subject: [PATCH 3/3] Fixes typo --- src/services/services.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/services.ts b/src/services/services.ts index 7493e894d1c..211b1358c50 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4642,7 +4642,7 @@ namespace ts { // Go to the original declaration for cases: // - // (1) when the aliased symbol was declared in location(parent). + // (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 &&