diff --git a/src/services/services.ts b/src/services/services.ts index 6761c487c6c..211b1358c50 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -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); } } 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();