mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 11:35:42 -06:00
Set up structure of prototype assignments
No actual binding happens yet though
This commit is contained in:
parent
116a8a8cff
commit
01f2ee3d1f
@ -2042,6 +2042,8 @@ namespace ts {
|
||||
case SpecialPropertyAssignmentKind.PrototypeProperty:
|
||||
bindPrototypePropertyAssignment((node as BinaryExpression).left as PropertyAccessEntityNameExpression, node);
|
||||
break;
|
||||
case SpecialPropertyAssignmentKind.Prototype:
|
||||
bindPrototypeAssignment(node as BinaryExpression);
|
||||
case SpecialPropertyAssignmentKind.ThisProperty:
|
||||
bindThisPropertyAssignment(node as BinaryExpression);
|
||||
break;
|
||||
@ -2361,8 +2363,13 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
/** For `x.prototype = { p, ... }`, declare members p,... if `x` is function/class/{}, or not declared. */
|
||||
function bindPrototypeAssignment(node: BinaryExpression) {
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* For 'x.prototype.y = z', declare a 'member' y on x if x is a function or class, or not declared.
|
||||
* For `x.prototype.y = z`, declare a member `y` on `x` if `x` is a function or class, or not declared.
|
||||
* Note that jsdoc preceding an ExpressionStatement like `x.prototype.y;` is also treated as a declaration.
|
||||
*/
|
||||
function bindPrototypePropertyAssignment(lhs: PropertyAccessEntityNameExpression, parent: Node) {
|
||||
|
||||
@ -14254,6 +14254,7 @@ namespace ts {
|
||||
case SpecialPropertyAssignmentKind.ModuleExports:
|
||||
case SpecialPropertyAssignmentKind.PrototypeProperty:
|
||||
case SpecialPropertyAssignmentKind.ThisProperty:
|
||||
case SpecialPropertyAssignmentKind.Prototype:
|
||||
return false;
|
||||
default:
|
||||
Debug.assertNever(kind);
|
||||
|
||||
@ -3964,7 +3964,9 @@ namespace ts {
|
||||
/// this.name = expr
|
||||
ThisProperty,
|
||||
// F.name = expr
|
||||
Property
|
||||
Property,
|
||||
// F.prototype = { ... }
|
||||
Prototype,
|
||||
}
|
||||
|
||||
export interface JsFileExtensionInfo {
|
||||
|
||||
@ -1590,6 +1590,10 @@ namespace ts {
|
||||
return SpecialPropertyAssignmentKind.Property;
|
||||
}
|
||||
}
|
||||
else if (lhs.name.escapedText === "prototype" && expr.right.kind === SyntaxKind.ObjectLiteralExpression) {
|
||||
// F.prototype = { ... }
|
||||
return SpecialPropertyAssignmentKind.Prototype;
|
||||
}
|
||||
else if (lhs.expression.kind === SyntaxKind.ThisKeyword) {
|
||||
return SpecialPropertyAssignmentKind.ThisProperty;
|
||||
}
|
||||
|
||||
@ -275,6 +275,7 @@ namespace ts.NavigationBar {
|
||||
case SpecialPropertyAssignmentKind.ExportsProperty:
|
||||
case SpecialPropertyAssignmentKind.ModuleExports:
|
||||
case SpecialPropertyAssignmentKind.PrototypeProperty:
|
||||
case SpecialPropertyAssignmentKind.Prototype:
|
||||
addNodeWithRecursiveChild(node, (node as BinaryExpression).right);
|
||||
break;
|
||||
case SpecialPropertyAssignmentKind.ThisProperty:
|
||||
|
||||
@ -370,6 +370,8 @@ namespace ts {
|
||||
case SpecialPropertyAssignmentKind.Property:
|
||||
// static method / property
|
||||
return isFunctionExpression(right) ? ScriptElementKind.memberFunctionElement : ScriptElementKind.memberVariableElement;
|
||||
case SpecialPropertyAssignmentKind.Prototype:
|
||||
return ScriptElementKind.localClassElement;
|
||||
default: {
|
||||
assertTypeIsNever(kind);
|
||||
return ScriptElementKind.unknown;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user