From 0de410627e1c2acafc0f73e97ec521a2c5befc2b Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Sun, 8 May 2016 15:59:15 -0700 Subject: [PATCH] Code review comments --- src/compiler/checker.ts | 2 +- src/compiler/utilities.ts | 1 - src/services/services.ts | 35 +++++++++++++---------------------- 3 files changed, 14 insertions(+), 24 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5a3bbaf918..351a218f82 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -16916,7 +16916,7 @@ namespace ts { } else if (symbol.flags & SymbolFlags.Transient) { let target: Symbol; - let next: Symbol = symbol; + let next = symbol; while (next = getSymbolLinks(next).target) { target = next; } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index f8b140c0ba..208723159c 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1568,7 +1568,6 @@ namespace ts { export function isLiteralComputedPropertyDeclarationName(node: Node) { return (node.kind === SyntaxKind.StringLiteral || node.kind === SyntaxKind.NumericLiteral) && node.parent.kind === SyntaxKind.ComputedPropertyName && - (node.parent).expression === node && isDeclaration(node.parent.parent); } diff --git a/src/services/services.ts b/src/services/services.ts index fdf291c328..8b89056abb 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -6453,30 +6453,21 @@ namespace ts { const contextualType = typeChecker.getContextualType(objectLiteral); const name = getNameFromObjectLiteralElement(node); if (name && contextualType) { + const result: Symbol[] = []; + const symbol = contextualType.getProperty(name); + if (symbol) { + result.push(symbol); + } + if (contextualType.flags & TypeFlags.Union) { - // This is a union type, first see if the property we are looking for is a union property (i.e. exists in all types) - // if not, search the constituent types for the property - const unionProperty = contextualType.getProperty(name); - if (unionProperty) { - return [unionProperty]; - } - else { - const result: Symbol[] = []; - forEach((contextualType).types, t => { - const symbol = t.getProperty(name); - if (symbol) { - result.push(symbol); - } - }); - return result; - } - } - else { - const symbol = contextualType.getProperty(name); - if (symbol) { - return [symbol]; - } + forEach((contextualType).types, t => { + const symbol = t.getProperty(name); + if (symbol) { + result.push(symbol); + } + }); } + return result; } return undefined; }