@@ -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,18 @@ 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
+ const possiblyVariableDeclaration = findAncestor ( location , ( node ) => {
5527
+ return isFunctionBlock ( node ) || isArrowFunctionBody ( node ) || isBindingPattern ( node ) ?
5528
+ "quit" : isVariableDeclaration ( node )
5529
+ } )
5530
+ return ( possiblyVariableDeclaration || possiblyParameterDeclaration ) as ParameterDeclaration | TypeParameterDeclaration | VariableDeclaration | undefined ;
5527
5531
}
5528
5532
5529
5533
function isArrowFunctionBody ( node : Node ) {
0 commit comments