Code cleanup

This commit is contained in:
Nathan Shively-Sanders 2018-02-22 11:19:44 -08:00
parent 41fba6f34b
commit d55aa22d15
2 changed files with 12 additions and 20 deletions

View File

@ -2353,14 +2353,13 @@ namespace ts {
if (node.expression.kind === SyntaxKind.ThisKeyword) {
bindThisPropertyAssignment(node);
}
else if (isEntityNameExpression(node) &&
isPropertyAccessExpression(node.expression) &&
node.expression.name.escapedText === "prototype" &&
node.parent.parent.kind === SyntaxKind.SourceFile) {
bindPrototypePropertyAssignment(node as PropertyAccessEntityNameExpression, node.parent);
}
else if (isEntityNameExpression(node) && node.parent.parent.kind === SyntaxKind.SourceFile) {
bindStaticPropertyAssignment(node as PropertyAccessEntityNameExpression);
if (isPropertyAccessExpression(node.expression) && node.expression.name.escapedText === "prototype") {
bindPrototypePropertyAssignment(node as PropertyAccessEntityNameExpression, node.parent);
}
else {
bindStaticPropertyAssignment(node as PropertyAccessEntityNameExpression);
}
}
}
@ -2368,7 +2367,8 @@ namespace ts {
function bindPrototypeAssignment(node: BinaryExpression) {
node.left.parent = node;
node.right.parent = node;
bindPropertyAssignment(node.left as PropertyAccessEntityNameExpression, node.left as PropertyAccessEntityNameExpression, /*isPrototypeProperty*/ false);
const lhs = node.left as PropertyAccessEntityNameExpression;
bindPropertyAssignment(lhs, lhs, /*isPrototypeProperty*/ false);
}
/**

View File

@ -1587,6 +1587,9 @@ namespace ts {
return SpecialPropertyAssignmentKind.None;
}
const lhs = expr.left;
if (lhs.expression.kind === SyntaxKind.ThisKeyword) {
return SpecialPropertyAssignmentKind.ThisProperty;
}
if (isIdentifier(lhs.expression)) {
if (lhs.expression.escapedText === "exports") {
// exports.name = expr
@ -1596,19 +1599,8 @@ namespace ts {
// module.exports = expr
return SpecialPropertyAssignmentKind.ModuleExports;
}
// TODO: Can probably unify these checks with those in the second half
else if (lhs.name.escapedText === "prototype") {
return SpecialPropertyAssignmentKind.Prototype;
}
else {
// F.x = expr
return SpecialPropertyAssignmentKind.Property;
}
}
else if (lhs.expression.kind === SyntaxKind.ThisKeyword) {
return SpecialPropertyAssignmentKind.ThisProperty;
}
else if (isEntityNameExpression(lhs.expression)) {
if (isEntityNameExpression(lhs.expression)) {
if (lhs.name.escapedText === "prototype" && isObjectLiteralExpression(expr.right)) {
// F.prototype = { ... }
return SpecialPropertyAssignmentKind.Prototype;