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) { else if (symbol.flags & SymbolFlags.Transient) {
let target: Symbol; let target: Symbol;
let next: Symbol = symbol; let next = symbol;
while (next = getSymbolLinks(next).target) { while (next = getSymbolLinks(next).target) {
target = next; target = next;
} }

View file

@ -1568,7 +1568,6 @@ namespace ts {
export function isLiteralComputedPropertyDeclarationName(node: Node) { export function isLiteralComputedPropertyDeclarationName(node: Node) {
return (node.kind === SyntaxKind.StringLiteral || node.kind === SyntaxKind.NumericLiteral) && return (node.kind === SyntaxKind.StringLiteral || node.kind === SyntaxKind.NumericLiteral) &&
node.parent.kind === SyntaxKind.ComputedPropertyName && node.parent.kind === SyntaxKind.ComputedPropertyName &&
(<ComputedPropertyName>node.parent).expression === node &&
isDeclaration(node.parent.parent); isDeclaration(node.parent.parent);
} }

View file

@ -6453,30 +6453,21 @@ namespace ts {
const contextualType = typeChecker.getContextualType(objectLiteral); const contextualType = typeChecker.getContextualType(objectLiteral);
const name = getNameFromObjectLiteralElement(node); const name = getNameFromObjectLiteralElement(node);
if (name && contextualType) { if (name && contextualType) {
const result: Symbol[] = [];
const symbol = contextualType.getProperty(name);
if (symbol) {
result.push(symbol);
}
if (contextualType.flags & TypeFlags.Union) { 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) forEach((<UnionType>contextualType).types, t => {
// if not, search the constituent types for the property const symbol = t.getProperty(name);
const unionProperty = contextualType.getProperty(name); if (symbol) {
if (unionProperty) { result.push(symbol);
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];
}
} }
return result;
} }
return undefined; return undefined;
} }