Skip to content

Commit

Permalink
feat(parser): support latest ESTree spec on optional chaining
Browse files Browse the repository at this point in the history
  • Loading branch information
3cp committed Jun 29, 2020
1 parent 1bf4d1c commit 055eb1c
Show file tree
Hide file tree
Showing 4 changed files with 636 additions and 187 deletions.
3 changes: 2 additions & 1 deletion src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ export const enum Flags {
SimpleParameterList = 1 << 7,
HasStrictReserved = 1 << 8,
StrictEvalArguments = 1 << 9,
DisallowCall = 1 << 10
DisallowCall = 1 << 10,
HasOptionalChaining = 1 << 11
}

export const enum HoistedClassFlags {
Expand Down
24 changes: 7 additions & 17 deletions src/estree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ export type Node =
| BlockStatement
| BreakStatement
| CallExpression
| OptionalExpression
| OptionalChain
| ChainExpression
| ImportExpression
| CatchClause
| ClassBody
Expand Down Expand Up @@ -154,8 +153,7 @@ export type Expression =
| BinaryExpression
| ConditionalExpression
| MetaProperty
| OptionalExpression
| OptionalChain
| ChainExpression
| JSXClosingElement
| JSXClosingFragment
| JSXExpressionContainer
Expand All @@ -181,8 +179,7 @@ export type JSXExpression = JSXEmptyExpression | JSXSpreadChild | JSXExpressionC
export type JSXTagNameExpression = JSXIdentifier | JSXMemberExpression | JSXNamespacedName;
export type LeftHandSideExpression =
| CallExpression
| OptionalExpression
| OptionalChain
| ChainExpression
| ImportExpression
| ClassExpression
| ClassDeclaration
Expand Down Expand Up @@ -346,17 +343,9 @@ export interface ImportExpression extends _Node {
source: Expression;
}

export interface OptionalExpression extends _Node {
type: 'OptionalExpression';
object: Expression;
chain: OptionalChain | MemberExpression;
}
export interface OptionalChain extends _Node {
type: 'OptionalChain';
base: Expression | null;
property?: Expression;
computed?: boolean;
arguments?: any;
export interface ChainExpression extends _Node {
type: 'ChainExpression';
expression: CallExpression | MemberExpression;
}

export interface CallExpression extends _Node {
Expand Down Expand Up @@ -639,6 +628,7 @@ export interface CoalesceExpression extends _Node {
left: Expression;
right: Expression;
}

export interface LogicalExpression extends _Node {
type: 'LogicalExpression';
operator: string;
Expand Down
Loading

0 comments on commit 055eb1c

Please sign in to comment.