@@ -2394,7 +2394,7 @@ export function getCompletionEntriesFromSymbols(
2394
2394
includeSymbol = false
2395
2395
) : UniqueNameSet {
2396
2396
const start = timestamp ( ) ;
2397
- const variableOrParameterDeclaration = getVariableOrParameterDeclaration ( contextToken ) ;
2397
+ const variableOrParameterDeclaration = getVariableOrParameterDeclaration ( contextToken , location ) ;
2398
2398
const useSemicolons = probablyUsesSemicolons ( sourceFile ) ;
2399
2399
const typeChecker = program . getTypeChecker ( ) ;
2400
2400
// Tracks unique names.
@@ -5464,14 +5464,20 @@ function isModuleSpecifierMissingOrEmpty(specifier: ModuleReference | Expression
5464
5464
return ! tryCast ( isExternalModuleReference ( specifier ) ? specifier . expression : specifier , isStringLiteralLike ) ?. text ;
5465
5465
}
5466
5466
5467
- function getVariableOrParameterDeclaration ( contextToken : Node | undefined ) {
5467
+ function getVariableOrParameterDeclaration ( contextToken : Node | undefined , location : Node ) {
5468
5468
if ( ! contextToken ) return ;
5469
5469
5470
- const declaration = findAncestor ( contextToken , node =>
5470
+ const possiblyParameterDeclaration = findAncestor ( contextToken , node =>
5471
5471
isFunctionBlock ( node ) || isArrowFunctionBody ( node ) || isBindingPattern ( node )
5472
5472
? "quit"
5473
- : isVariableDeclaration ( node ) || ( ( isParameter ( node ) || isTypeParameterDeclaration ( node ) ) && ! isIndexSignatureDeclaration ( node . parent ) ) ) ;
5474
- return declaration as ParameterDeclaration | TypeParameterDeclaration | VariableDeclaration | undefined ;
5473
+ : ( ( isParameter ( node ) || isTypeParameterDeclaration ( node ) ) && ! isIndexSignatureDeclaration ( node . parent ) ) ) ;
5474
+
5475
+ const possiblyVariableDeclaration = findAncestor ( location , node =>
5476
+ isFunctionBlock ( node ) || isArrowFunctionBody ( node ) || isBindingPattern ( node )
5477
+ ? "quit"
5478
+ : isVariableDeclaration ( node ) ) ;
5479
+
5480
+ return ( possiblyParameterDeclaration || possiblyVariableDeclaration ) as ParameterDeclaration | TypeParameterDeclaration | VariableDeclaration | undefined ;
5475
5481
}
5476
5482
5477
5483
function isArrowFunctionBody ( node : Node ) {
0 commit comments