Make go-to-implementation never return ambient results

This commit is contained in:
Andrew Branch
2022-03-10 14:32:44 -08:00
parent f2915e6c80
commit 309c4bbf59
5 changed files with 5 additions and 8 deletions

View File

@@ -41493,9 +41493,6 @@ namespace ts {
return getSymbolOfNode(node as BinaryExpression) || getSymbolOfNode((node as BinaryExpression).left);
default:
if (isDeclaration(node)) {
return getSymbolOfNode(node);
}
return undefined;
}
}

View File

@@ -1312,7 +1312,7 @@ namespace ts.server {
const fileToSearch = Debug.checkDefined(auxiliaryProgram.getSourceFile(fileNameToSearch!));
const matches = FindAllReferences.Core.getTopMostDeclarationsInFile(candidate.name, fileToSearch);
for (const match of matches) {
const symbol = auxiliaryProgram.getTypeChecker().getSymbolAtLocation(match);
const symbol = match.symbol || auxiliaryProgram.getTypeChecker().getSymbolAtLocation(match);
if (symbol) {
pushIfUnique(definitions, GoToDefinition.createDefinitionInfo(match, auxiliaryProgram.getTypeChecker(), symbol, match));
}

View File

@@ -2296,10 +2296,10 @@ namespace ts.FindAllReferences {
}
function isImplementation(node: Node): boolean {
return !!(node.flags & NodeFlags.Ambient) ? !(isInterfaceDeclaration(node) || isTypeAliasDeclaration(node)) :
return !(node.flags & NodeFlags.Ambient) && (
(isVariableLike(node) ? hasInitializer(node) :
isFunctionLikeDeclaration(node) ? !!node.body :
isClassLike(node) || isModuleOrEnumDeclaration(node));
isClassLike(node) || isModuleOrEnumDeclaration(node)));
}
export function getReferenceEntriesForShorthandPropertyAssignment(node: Node, checker: TypeChecker, addReference: (node: Node) => void): void {

View File

@@ -5,4 +5,4 @@
//// declare var [|someVar|]: string;
//// someVa/*reference*/r
verify.allRangesAppearInImplementationList("reference");
verify.implementationListIsEmpty();

View File

@@ -5,4 +5,4 @@
//// declare function [|someFunction|](): () => void;
//// someFun/*reference*/ction();
verify.allRangesAppearInImplementationList("reference");
verify.implementationListIsEmpty();