@@ -2439,7 +2439,7 @@ export function getCompletionEntriesFromSymbols(
2439
2439
includeSymbol = false
2440
2440
) : UniqueNameSet {
2441
2441
const start = timestamp ( ) ;
2442
- const variableOrParameterDeclaration = getVariableOrParameterDeclaration ( contextToken ) ;
2442
+ const variableOrParameterDeclaration = getVariableOrParameterDeclaration ( contextToken , location ) ;
2443
2443
const useSemicolons = probablyUsesSemicolons ( sourceFile ) ;
2444
2444
const typeChecker = program . getTypeChecker ( ) ;
2445
2445
// Tracks unique names.
@@ -5516,14 +5516,20 @@ function isModuleSpecifierMissingOrEmpty(specifier: ModuleReference | Expression
5516
5516
return ! tryCast ( isExternalModuleReference ( specifier ) ? specifier . expression : specifier , isStringLiteralLike ) ?. text ;
5517
5517
}
5518
5518
5519
- function getVariableOrParameterDeclaration ( contextToken : Node | undefined ) {
5519
+ function getVariableOrParameterDeclaration ( contextToken : Node | undefined , location : Node ) {
5520
5520
if ( ! contextToken ) return ;
5521
5521
5522
- const declaration = findAncestor ( contextToken , node =>
5522
+ const possiblyParameterDeclaration = findAncestor ( contextToken , node =>
5523
5523
isFunctionBlock ( node ) || isArrowFunctionBody ( node ) || isBindingPattern ( node )
5524
5524
? "quit"
5525
- : isVariableDeclaration ( node ) || ( ( isParameter ( node ) || isTypeParameterDeclaration ( node ) ) && ! isIndexSignatureDeclaration ( node . parent ) ) ) ;
5526
- return declaration as ParameterDeclaration | TypeParameterDeclaration | VariableDeclaration | undefined ;
5525
+ : ( ( isParameter ( node ) || isTypeParameterDeclaration ( node ) ) && ! isIndexSignatureDeclaration ( node . parent ) ) ) ;
5526
+
5527
+ const possiblyVariableDeclaration = findAncestor ( location , node =>
5528
+ isFunctionBlock ( node ) || isArrowFunctionBody ( node ) || isBindingPattern ( node )
5529
+ ? "quit"
5530
+ : isVariableDeclaration ( node ) ) ;
5531
+
5532
+ return ( possiblyParameterDeclaration || possiblyVariableDeclaration ) as ParameterDeclaration | TypeParameterDeclaration | VariableDeclaration | undefined ;
5527
5533
}
5528
5534
5529
5535
function isArrowFunctionBody ( node : Node ) {
0 commit comments