@@ -2439,7 +2439,7 @@ export function getCompletionEntriesFromSymbols(
24392439 includeSymbol = false
24402440) : UniqueNameSet {
24412441 const start = timestamp ( ) ;
2442- const variableOrParameterDeclaration = getVariableOrParameterDeclaration ( contextToken ) ;
2442+ const variableOrParameterDeclaration = getVariableOrParameterDeclaration ( contextToken , location ) ;
24432443 const useSemicolons = probablyUsesSemicolons ( sourceFile ) ;
24442444 const typeChecker = program . getTypeChecker ( ) ;
24452445 // Tracks unique names.
@@ -5516,14 +5516,18 @@ function isModuleSpecifierMissingOrEmpty(specifier: ModuleReference | Expression
55165516 return ! tryCast ( isExternalModuleReference ( specifier ) ? specifier . expression : specifier , isStringLiteralLike ) ?. text ;
55175517}
55185518
5519- function getVariableOrParameterDeclaration ( contextToken : Node | undefined ) {
5519+ function getVariableOrParameterDeclaration ( contextToken : Node | undefined , location : Node ) {
55205520 if ( ! contextToken ) return ;
55215521
5522- const declaration = findAncestor ( contextToken , node =>
5522+ const possiblyParameterDeclaration = findAncestor ( contextToken , node =>
55235523 isFunctionBlock ( node ) || isArrowFunctionBody ( node ) || isBindingPattern ( node )
55245524 ? "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 ;
55275531}
55285532
55295533function isArrowFunctionBody ( node : Node ) {
0 commit comments