Code review comments

This commit is contained in:
Mohamed Hegazy 2016-05-08 15:59:15 -07:00
parent 02bae234c6
commit 0de410627e
3 changed files with 14 additions and 24 deletions

View file

@ -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;
}

View file

@ -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 &&
(<ComputedPropertyName>node.parent).expression === node &&
isDeclaration(node.parent.parent);
}

View file

@ -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((<UnionType>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((<UnionType>contextualType).types, t => {
const symbol = t.getProperty(name);
if (symbol) {
result.push(symbol);
}
});
}
return result;
}
return undefined;
}