Merge pull request #3698 from Microsoft/noObjectBindingBuilder

Don't show a builder for property names in object binding patterns
This commit is contained in:
Daniel Rosenwasser
2015-07-06 16:37:43 -07:00
12 changed files with 35 additions and 14 deletions

View File

@@ -3013,21 +3013,30 @@ namespace ts {
let objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken);
let jsxContainer = tryGetContainingJsxElement(contextToken);
if (objectLikeContainer) {
// Object literal expression, look up possible property names from contextual type
// We're looking up possible property names from contextual/inferred/declared type.
isMemberCompletion = true;
isNewIdentifierLocation = true;
let typeForObject: Type;
let existingMembers: Declaration[];
if (objectLikeContainer.kind === SyntaxKind.ObjectLiteralExpression) {
// We are completing on contextual types, but may also include properties
// other than those within the declared type.
isNewIdentifierLocation = true;
typeForObject = typeChecker.getContextualType(<ObjectLiteralExpression>objectLikeContainer);
existingMembers = (<ObjectLiteralExpression>objectLikeContainer).properties;
}
else {
else if (objectLikeContainer.kind === SyntaxKind.ObjectBindingPattern) {
// We are *only* completing on properties from the type being destructured.
isNewIdentifierLocation = false;
typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer);
existingMembers = (<BindingPattern>objectLikeContainer).elements;
}
else {
Debug.fail("Expected object literal or binding pattern, got " + objectLikeContainer.kind);
}
if (!typeForObject) {
return false;