Modify grammar to support Private Fields proposal: (#260)
* Modify grammar to support Private Fields proposal: - Adding optional plugin `classPrivateProperties` - Adding PrivateName type identifier - Adding ClassPrivateProperty to ClassBody - Allow PrivateName in MemberExpression - Allow PrivateName as a reference - Adding tests * Remove unnecesary liberal parameter * Guarding for plugin dependecy for future versioning * update spec.md [skip ci] * move comment [skip ci] * remove unused param [skip ci] * Refactor PrivateName to contain Identifier in name property
This commit is contained in:
committed by
Henry Zhu
parent
6c4acecf00
commit
01da62283c
26
ast/spec.md
26
ast/spec.md
@@ -3,6 +3,7 @@ These are the core Babylon AST node types.
|
||||
- [Node objects](#node-objects)
|
||||
- [Changes](#changes)
|
||||
- [Identifier](#identifier)
|
||||
- [PrivateName](#privatename)
|
||||
- [Literals](#literals)
|
||||
- [RegExpLiteral](#regexpliteral)
|
||||
- [NullLiteral](#nullliteral)
|
||||
@@ -90,6 +91,7 @@ These are the core Babylon AST node types.
|
||||
- [ClassBody](#classbody)
|
||||
- [ClassMethod](#classmethod)
|
||||
- [ClassProperty](#classproperty)
|
||||
- [ClassPrivateProperty](#classprivateproperty)
|
||||
- [ClassDeclaration](#classdeclaration)
|
||||
- [ClassExpression](#classexpression)
|
||||
- [MetaProperty](#metaproperty)
|
||||
@@ -166,6 +168,18 @@ interface Identifier <: Expression, Pattern {
|
||||
|
||||
An identifier. Note that an identifier may be an expression or a destructuring pattern.
|
||||
|
||||
|
||||
# PrivateName
|
||||
|
||||
```js
|
||||
interface PrivateName <: Expression, Pattern {
|
||||
type: "PrivateName";
|
||||
name: Identifier;
|
||||
}
|
||||
```
|
||||
A Private Name Identifier.
|
||||
|
||||
|
||||
# Literals
|
||||
|
||||
```js
|
||||
@@ -1015,7 +1029,7 @@ interface Class <: Node {
|
||||
```js
|
||||
interface ClassBody <: Node {
|
||||
type: "ClassBody";
|
||||
body: [ ClassMethod | ClassProperty ];
|
||||
body: [ ClassMethod | ClassProperty | ClassPrivateProperty ];
|
||||
}
|
||||
```
|
||||
|
||||
@@ -1043,6 +1057,16 @@ interface ClassProperty <: Node {
|
||||
}
|
||||
```
|
||||
|
||||
## ClassPrivateProperty
|
||||
|
||||
```js
|
||||
interface ClassPrivateProperty <: Node {
|
||||
type: "ClassPrivateProperty";
|
||||
key: Identifier;
|
||||
value: Expression;
|
||||
}
|
||||
```
|
||||
|
||||
## ClassDeclaration
|
||||
|
||||
```js
|
||||
|
||||
Reference in New Issue
Block a user