docs: add AST spec on optional chain [skip ci] (#11729)
This commit is contained in:
parent
3d498d05e7
commit
b1b21e5c03
@ -77,9 +77,11 @@ These are the core @babel/parser (babylon) AST node types.
|
|||||||
- [SpreadElement](#spreadelement)
|
- [SpreadElement](#spreadelement)
|
||||||
- [ArgumentPlaceholder](#argumentplaceholder)
|
- [ArgumentPlaceholder](#argumentplaceholder)
|
||||||
- [MemberExpression](#memberexpression)
|
- [MemberExpression](#memberexpression)
|
||||||
|
- [OptionalMemberExpression](#optionalmemberexpression)
|
||||||
- [BindExpression](#bindexpression)
|
- [BindExpression](#bindexpression)
|
||||||
- [ConditionalExpression](#conditionalexpression)
|
- [ConditionalExpression](#conditionalexpression)
|
||||||
- [CallExpression](#callexpression)
|
- [CallExpression](#callexpression)
|
||||||
|
- [OptionalCallExpression](#optionalcallexpression)
|
||||||
- [NewExpression](#newexpression)
|
- [NewExpression](#newexpression)
|
||||||
- [SequenceExpression](#sequenceexpression)
|
- [SequenceExpression](#sequenceexpression)
|
||||||
- [ParenthesizedExpression](#parenthesizedexpression)
|
- [ParenthesizedExpression](#parenthesizedexpression)
|
||||||
@ -176,17 +178,16 @@ interface Identifier <: Expression, Pattern {
|
|||||||
|
|
||||||
An identifier. Note that an identifier may be an expression or a destructuring pattern.
|
An identifier. Note that an identifier may be an expression or a destructuring pattern.
|
||||||
|
|
||||||
|
|
||||||
# PrivateName
|
# PrivateName
|
||||||
|
|
||||||
```js
|
```js
|
||||||
interface PrivateName <: Expression, Pattern {
|
interface PrivateName <: Node {
|
||||||
type: "PrivateName";
|
type: "PrivateName";
|
||||||
id: Identifier;
|
id: Identifier;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
A Private Name Identifier.
|
|
||||||
|
|
||||||
|
A Private Name Identifier.
|
||||||
|
|
||||||
# Literals
|
# Literals
|
||||||
|
|
||||||
@ -817,12 +818,12 @@ An update (increment or decrement) operator token.
|
|||||||
interface BinaryExpression <: Expression {
|
interface BinaryExpression <: Expression {
|
||||||
type: "BinaryExpression";
|
type: "BinaryExpression";
|
||||||
operator: BinaryOperator;
|
operator: BinaryOperator;
|
||||||
left: Expression;
|
left: Expression | PrivateName;
|
||||||
right: Expression;
|
right: Expression;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
A binary operator expression.
|
A binary operator expression. When `operator` is `in`, the `left` can be a `PrivateName`.
|
||||||
|
|
||||||
#### BinaryOperator
|
#### BinaryOperator
|
||||||
|
|
||||||
@ -912,13 +913,27 @@ interface ArgumentPlaceholder <: Node {
|
|||||||
interface MemberExpression <: Expression, Pattern {
|
interface MemberExpression <: Expression, Pattern {
|
||||||
type: "MemberExpression";
|
type: "MemberExpression";
|
||||||
object: Expression | Super;
|
object: Expression | Super;
|
||||||
property: Expression;
|
property: Expression | PrivateName;
|
||||||
computed: boolean;
|
computed: boolean;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
A member expression. If `computed` is `true`, the node corresponds to a computed (`a[b]`) member expression and `property` is an `Expression`. If `computed` is `false`, the node corresponds to a static (`a.b`) member expression and `property` is an `Identifier` or a `PrivateName`.
|
A member expression. If `computed` is `true`, the node corresponds to a computed (`a[b]`) member expression and `property` is an `Expression`. If `computed` is `false`, the node corresponds to a static (`a.b`) member expression and `property` is an `Identifier` or a `PrivateName`.
|
||||||
|
|
||||||
|
### OptionalMemberExpression
|
||||||
|
|
||||||
|
```js
|
||||||
|
interface OptionalMemberExpression <: Expression {
|
||||||
|
type: "OptionalMemberExpression";
|
||||||
|
object: Expression;
|
||||||
|
property: Expression | PrivateName;
|
||||||
|
computed: boolean;
|
||||||
|
optional: boolean;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
An optional member expression is a part of the optional chain. When `optional` is `true`, it is the starting element of the optional chain. i.e. In `a?.b.c`, `?.b` is an optional member expression with `optional: true`, `.c` is an optional member expression. See this [gist](https://gist.github.com/JLHwung/567fb29fa2b82bbe164ad9067ff3290f) for more AST examples.
|
||||||
|
|
||||||
### BindExpression
|
### BindExpression
|
||||||
|
|
||||||
```js
|
```js
|
||||||
@ -1004,6 +1019,19 @@ interface CallExpression <: Expression {
|
|||||||
|
|
||||||
A function or method call expression. When the `callee` is `Import`, the `arguments` must have only one `Expression` element.
|
A function or method call expression. When the `callee` is `Import`, the `arguments` must have only one `Expression` element.
|
||||||
|
|
||||||
|
## OptionalCallExpression
|
||||||
|
|
||||||
|
```js
|
||||||
|
interface OptionalCallExpression <: Expression {
|
||||||
|
type: "OptionalCallExpression";
|
||||||
|
callee: Expression;
|
||||||
|
arguments: [ Expression | SpreadElement ];
|
||||||
|
optional: boolean;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
An optional call expression is a part of the optional chain. When `optional` is `true`, it is the starting element of the optional chain. i.e. In `f?.()()`, `?.()` is an optional call expression with `optional: true`, `()` is an optional call expression with `optional: false`. See this [gist](https://gist.github.com/JLHwung/567fb29fa2b82bbe164ad9067ff3290f) for more AST examples.
|
||||||
|
|
||||||
## NewExpression
|
## NewExpression
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user