Skip to content

Commit 4a2e672

Browse files
Don't show a builder in object binding pattern completions.
1 parent 4082a54 commit 4a2e672

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/services/services.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3010,18 +3010,24 @@ namespace ts {
30103010
function tryGetGlobalSymbols(): boolean {
30113011
let objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken);
30123012
if (objectLikeContainer) {
3013-
// Object literal expression, look up possible property names from contextual type
3013+
// We're looking up possible property names from contextual/inferred/declared type.
30143014
isMemberCompletion = true;
3015-
isNewIdentifierLocation = true;
30163015

30173016
let typeForObject: Type;
30183017
let existingMembers: Declaration[];
30193018

30203019
if (objectLikeContainer.kind === SyntaxKind.ObjectLiteralExpression) {
3020+
// We are completing on contextual types, but may also include properties
3021+
// other than those within the declared type.
3022+
isNewIdentifierLocation = true;
3023+
30213024
typeForObject = typeChecker.getContextualType(<ObjectLiteralExpression>objectLikeContainer);
30223025
existingMembers = (<ObjectLiteralExpression>objectLikeContainer).properties;
30233026
}
30243027
else {
3028+
// We are *only* completing on properties from the type being destructured.
3029+
isNewIdentifierLocation = false;
3030+
30253031
typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer);
30263032
existingMembers = (<BindingPattern>objectLikeContainer).elements;
30273033
}

0 commit comments

Comments
 (0)