mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 21:06:50 -05:00
Fix sending correct symbol when using commonjs require and destructuring (#43511)
* Fix sending correct symbol when using commonjs require and destructuring * Check BindingElement
This commit is contained in:
@@ -1477,7 +1477,7 @@ namespace ts.FindAllReferences {
|
||||
|
||||
if (!hasMatchingMeaning(referenceLocation, state)) return;
|
||||
|
||||
const referenceSymbol = state.checker.getSymbolAtLocation(referenceLocation);
|
||||
let referenceSymbol = state.checker.getSymbolAtLocation(referenceLocation);
|
||||
if (!referenceSymbol) {
|
||||
return;
|
||||
}
|
||||
@@ -1514,6 +1514,11 @@ namespace ts.FindAllReferences {
|
||||
Debug.assertNever(state.specialSearchKind);
|
||||
}
|
||||
|
||||
// Use the parent symbol if the location is commonjs require syntax on javascript files only.
|
||||
referenceSymbol = isInJSFile(referenceLocation) && referenceLocation.parent.kind === SyntaxKind.BindingElement && isRequireVariableDeclaration(referenceLocation.parent)
|
||||
? referenceLocation.parent.symbol
|
||||
: referenceSymbol;
|
||||
|
||||
getImportOrExportReferences(referenceLocation, referenceSymbol, search, state);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user