mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 03:23:08 -06:00
Code cleanup
This commit is contained in:
parent
41fba6f34b
commit
d55aa22d15
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user