Skip to content

Commit 6accbdf

Browse files
Generalize logic for upcoming work on object binding completion.
1 parent 30ec5f9 commit 6accbdf

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/services/services.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2985,8 +2985,8 @@ namespace ts {
29852985
}
29862986

29872987
function tryGetGlobalSymbols(): boolean {
2988-
let containingObjectLiteral = getContainingObjectLiteralApplicableForCompletion(contextToken);
2989-
if (containingObjectLiteral) {
2988+
let containingObjectLiteral = <ObjectLiteralExpression>getContainingObjectLiteralOrBindingPatternIfApplicableForCompletion(contextToken);
2989+
if (containingObjectLiteral && containingObjectLiteral.kind === SyntaxKind.ObjectLiteralExpression) {
29902990
// Object literal expression, look up possible property names from contextual type
29912991
isMemberCompletion = true;
29922992
isNewIdentifierLocation = true;
@@ -3187,16 +3187,16 @@ namespace ts {
31873187
return false;
31883188
}
31893189

3190-
function getContainingObjectLiteralApplicableForCompletion(contextToken: Node): ObjectLiteralExpression {
3190+
function getContainingObjectLiteralOrBindingPatternIfApplicableForCompletion(contextToken: Node): ObjectLiteralExpression | BindingPattern {
31913191
// The locations in an object literal expression that
31923192
// are applicable for completion are property name definition locations.
31933193
if (contextToken) {
31943194
switch (contextToken.kind) {
31953195
case SyntaxKind.OpenBraceToken: // let x = { |
31963196
case SyntaxKind.CommaToken: // let x = { a: 0, |
31973197
let parent = contextToken.parent;
3198-
if (parent && parent.kind === SyntaxKind.ObjectLiteralExpression) {
3199-
return <ObjectLiteralExpression>parent;
3198+
if (parent && (parent.kind === SyntaxKind.ObjectLiteralExpression || parent.kind === SyntaxKind.ObjectBindingPattern)) {
3199+
return <ObjectLiteralExpression | BindingPattern>parent;
32003200
}
32013201
break;
32023202
}

0 commit comments

Comments
 (0)