mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Exclude completions of binding pattern variable initializers (#52723)
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
This commit is contained in:
1 parent
7205eda454
commit
ba663f6ac2
2 files changed
+35
-2
No files matched your search
@@ -2745,8 +2745,14 @@ export function getCompletionEntriesFromSymbols(
|
||||
}
|
||||
// Filter out variables from their own initializers
|
||||
// `const a = /* no 'a' here */`
|
||||
if (tryCast(closestSymbolDeclaration, isVariableDeclaration) && symbol.valueDeclaration === closestSymbolDeclaration) {
|
||||
return false;
|
||||
if (closestSymbolDeclaration && tryCast(closestSymbolDeclaration, isVariableDeclaration)) {
|
||||
if (symbol.valueDeclaration === closestSymbolDeclaration) {
|
||||
return false;
|
||||
}
|
||||
// const { a } = /* no 'a' here */;
|
||||
if (isBindingPattern(closestSymbolDeclaration.name) && closestSymbolDeclaration.name.elements.some(e => e === symbol.valueDeclaration)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Filter out current and latter parameters from defaults
|
||||
|
||||
@@ -9,6 +9,10 @@
|
||||
//// const fn = (p = /*7*/) => {}
|
||||
//// const { g, h = /*8*/ } = { ... }
|
||||
//// const [ g1, h1 = /*9*/ ] = [ ... ]
|
||||
//// const { a1 } = a/*10*/;
|
||||
//// const { a2 } = fn({a: a/*11*/});
|
||||
//// const [ a3 ] = a/*12*/;
|
||||
//// const [ a4 ] = fn([a/*13*/]);
|
||||
|
||||
verify.completions({
|
||||
marker: ["1"],
|
||||
@@ -58,3 +62,26 @@ verify.completions({
|
||||
marker: ["9"],
|
||||
includes: ["a", "b", "c", "d", "e", "fn"],
|
||||
});
|
||||
|
||||
verify.completions({
|
||||
marker: ["10"],
|
||||
excludes: ["a1"],
|
||||
isNewIdentifierLocation: true,
|
||||
});
|
||||
|
||||
verify.completions({
|
||||
marker: ["11"],
|
||||
excludes: ["a2"],
|
||||
});
|
||||
|
||||
verify.completions({
|
||||
marker: ["12"],
|
||||
excludes: ["a3"],
|
||||
isNewIdentifierLocation: true,
|
||||
});
|
||||
|
||||
verify.completions({
|
||||
marker: ["13"],
|
||||
excludes: ["a4"],
|
||||
isNewIdentifierLocation: true,
|
||||
});
|
||||
Reference in new issue
Block a user