Skip to content

Commit d62bcc5

Browse files
committed
exclude completions of binding pattern variable initializers
1 parent 4849947 commit d62bcc5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/services/completions.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2468,8 +2468,14 @@ export function getCompletionEntriesFromSymbols(
24682468
}
24692469
// Filter out variables from their own initializers
24702470
// `const a = /* no 'a' here */`
2471-
if (tryCast(variableOrParameterDeclaration, isVariableDeclaration) && symbol.valueDeclaration === variableOrParameterDeclaration) {
2472-
return false;
2471+
if (variableOrParameterDeclaration && tryCast(variableOrParameterDeclaration, isVariableDeclaration)) {
2472+
if (symbol.valueDeclaration === variableOrParameterDeclaration) {
2473+
return false;
2474+
}
2475+
// const { a } = /* no 'a' here */;
2476+
if (isBindingPattern(variableOrParameterDeclaration.name) && variableOrParameterDeclaration.name.elements.some(e => e === symbol.valueDeclaration)) {
2477+
return false;
2478+
}
24732479
}
24742480

24752481
// Filter out parameters from their own initializers

0 commit comments

Comments
 (0)