Skip to content

Commit 309c4bb

Browse files
committed
Make go-to-implementation never return ambient results
1 parent f2915e6 commit 309c4bb

File tree

5 files changed

+5
-8
lines changed

5 files changed

+5
-8
lines changed

src/compiler/checker.ts

-3
Original file line numberDiff line numberDiff line change
@@ -41493,9 +41493,6 @@ namespace ts {
4149341493
return getSymbolOfNode(node as BinaryExpression) || getSymbolOfNode((node as BinaryExpression).left);
4149441494

4149541495
default:
41496-
if (isDeclaration(node)) {
41497-
return getSymbolOfNode(node);
41498-
}
4149941496
return undefined;
4150041497
}
4150141498
}

src/server/session.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1312,7 +1312,7 @@ namespace ts.server {
13121312
const fileToSearch = Debug.checkDefined(auxiliaryProgram.getSourceFile(fileNameToSearch!));
13131313
const matches = FindAllReferences.Core.getTopMostDeclarationsInFile(candidate.name, fileToSearch);
13141314
for (const match of matches) {
1315-
const symbol = auxiliaryProgram.getTypeChecker().getSymbolAtLocation(match);
1315+
const symbol = match.symbol || auxiliaryProgram.getTypeChecker().getSymbolAtLocation(match);
13161316
if (symbol) {
13171317
pushIfUnique(definitions, GoToDefinition.createDefinitionInfo(match, auxiliaryProgram.getTypeChecker(), symbol, match));
13181318
}

src/services/findAllReferences.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2296,10 +2296,10 @@ namespace ts.FindAllReferences {
22962296
}
22972297

22982298
function isImplementation(node: Node): boolean {
2299-
return !!(node.flags & NodeFlags.Ambient) ? !(isInterfaceDeclaration(node) || isTypeAliasDeclaration(node)) :
2299+
return !(node.flags & NodeFlags.Ambient) && (
23002300
(isVariableLike(node) ? hasInitializer(node) :
23012301
isFunctionLikeDeclaration(node) ? !!node.body :
2302-
isClassLike(node) || isModuleOrEnumDeclaration(node));
2302+
isClassLike(node) || isModuleOrEnumDeclaration(node)));
23032303
}
23042304

23052305
export function getReferenceEntriesForShorthandPropertyAssignment(node: Node, checker: TypeChecker, addReference: (node: Node) => void): void {

tests/cases/fourslash/goToImplementationLocal_06.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
//// declare var [|someVar|]: string;
66
//// someVa/*reference*/r
77

8-
verify.allRangesAppearInImplementationList("reference");
8+
verify.implementationListIsEmpty();

tests/cases/fourslash/goToImplementationLocal_07.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
//// declare function [|someFunction|](): () => void;
66
//// someFun/*reference*/ction();
77

8-
verify.allRangesAppearInImplementationList("reference");
8+
verify.implementationListIsEmpty();

0 commit comments

Comments
 (0)