- Expressions and Patterns
- Array Pattern
- Assignment Pattern
- Object Pattern
- This Expression
- Identifier
- Literal
- Array Expression
- Object Expression
- Function Expression
- Arrow Function Expression
- Class Expression
- Tagged Template Expression
- Member Expression
- Super
- MetaProperty
- Call and New Expressions
- Update Expression
- Await Expression
- Unary Expression
- Binary Expression
- Logical Expression
- Conditional Expression
- Yield Expression
- Assignment Expression
- Sequence Expression
Expressions and Patterns
A binding pattern can be one of the following:
- type BindingPattern = ArrayPattern | ObjectPattern;
An expression can be one of the following:
- type Expression = ThisExpression | Identifier | Literal |
- ArrayExpression | ObjectExpression | FunctionExpression | ArrowFunctionExpression | ClassExpression |
- TaggedTemplateExpression | MemberExpression | Super | MetaProperty |
- NewExpression | CallExpression | UpdateExpression | AwaitExpression | UnaryExpression |
- BinaryExpression | LogicalExpression | ConditionalExpression |
- YieldExpression | AssignmentExpression | SequenceExpression;
Array Pattern
- interface ArrayPattern {
- type: 'ArrayPattern';
- elements: ArrayPatternElement[];
- }
with
- type ArrayPatternElement = AssignmentPattern | Identifier | BindingPattern | RestElement | null;
- interface RestElement {
- type: 'RestElement';
- argument: Identifier | BindingPattern;
- }
Assignment Pattern
- interface AssignmentPattern {
- type: 'AssignmentPattern';
- left: Identifier | BindingPattern;
- right: Expression;
- }
Object Pattern
- interface ObjectPattern {
- type: 'ObjectPattern';
- properties: Property[];
- }
This Expression
- interface ThisExpression {
- type: 'ThisExpression';
- }
Identifier
- interface Identifier {
- type: 'Identifier';
- name: string;
- }
Literal
- interface Literal {
- type: 'Literal';
- value: boolean | number | string | RegExp | null;
- raw: string;
- regex?: { pattern: string, flags: string };
- }
The regex
property only applies to regular expression literals.
Array Expression
- interface ArrayExpression {
- type: 'ArrayExpression';
- elements: ArrayExpressionElement[];
- }
where
- type ArrayExpressionElement = Expression | SpreadElement;
Object Expression
- interface ObjectExpression {
- type: 'ObjectExpression';
- properties: Property[];
- }
where
- interface Property {
- type: 'Property';
- key: Expression;
- computed: boolean;
- value: Expression | null;
- kind: 'get' | 'set' | 'init';
- method: false;
- shorthand: boolean;
- }
Function Expression
- interface FunctionExpression {
- type: 'FunctionExpression';
- id: Identifier | null;
- params: FunctionParameter[];
- body: BlockStatement;
- generator: boolean;
- async: boolean;
- expression: boolean;
- }
with
- type FunctionParameter = AssignmentPattern | Identifier | BindingPattern;
The value of generator
is true for a generator expression.
Arrow Function Expression
- interface ArrowFunctionExpression {
- type: 'ArrowFunctionExpression';
- id: Identifier | null;
- params: FunctionParameter[];
- body: BlockStatement | Expression;
- generator: boolean;
- async: boolean;
- expression: false;
- }
Class Expression
- interface ClassExpression {
- type: 'ClassExpression';
- id: Identifier | null;
- superClass: Identifier | null;
- body: ClassBody;
- }
with
- interface ClassBody {
- type: 'ClassBody';
- body: MethodDefinition[];
- }
- interface MethodDefinition {
- type: 'MethodDefinition';
- key: Expression | null;
- computed: boolean;
- value: FunctionExpression | null;
- kind: 'method' | 'constructor';
- static: boolean;
- }
Tagged Template Expression
- interface TaggedTemplateExpression {
- type: 'TaggedTemplateExpression';
- readonly tag: Expression;
- readonly quasi: TemplateLiteral;
- }
with
- interface TemplateElement {
- type: 'TemplateElement';
- value: { cooked: string; raw: string };
- tail: boolean;
- }
- interface TemplateLiteral {
- type: 'TemplateLiteral';
- quasis: TemplateElement[];
- expressions: Expression[];
- }
Member Expression
- interface MemberExpression {
- type: 'MemberExpression';
- computed: boolean;
- object: Expression;
- property: Expression;
- }
Super
- interface Super {
- type: 'Super';
- }
MetaProperty
- interface MetaProperty {
- type: 'MetaProperty';
- meta: Identifier;
- property: Identifier;
- }
Call and New Expressions
- interface CallExpression {
- type: 'CallExpression';
- callee: Expression;
- arguments: ArgumentListElement[];
- }
- interface NewExpression {
- type: 'NewExpression';
- callee: Expression;
- arguments: ArgumentListElement[];
- }
with
- type ArgumentListElement = Expression | SpreadElement;
- interface SpreadElement {
- type: 'SpreadElement';
- argument: Expression;
- }
Update Expression
- interface UpdateExpression {
- type: 'UpdateExpression';
- operator: '++' | '--';
- argument: Expression;
- prefix: boolean;
- }
Await Expression
- interface AwaitExpression {
- type: 'AwaitExpression';
- argument: Expression;
- }
Unary Expression
- interface UnaryExpression {
- type: 'UnaryExpression';
- operator: '+' | '-' | '~' | '!' | 'delete' | 'void' | 'typeof';
- argument: Expression;
- prefix: true;
- }
Binary Expression
- interface BinaryExpression {
- type: 'BinaryExpression';
- operator: 'instanceof' | 'in' | '+' | '-' | '*' | '/' | '%' | '**' |
- '|' | '^' | '&' | '==' | '!=' | '===' | '!==' |
- '<' | '>' | '<=' | '<<' | '>>' | '>>>';
- left: Expression;
- right: Expression;
- }
Logical Expression
- interface LogicalExpression {
- type: 'LogicalExpression';
- operator: '||' | '&&';
- left: Expression;
- right: Expression;
- }
Conditional Expression
- interface ConditionalExpression {
- type: 'ConditionalExpression';
- test: Expression;
- consequent: Expression;
- alternate: Expression;
- }
Yield Expression
- interface YieldExpression {
- type: 'YieldExpression';
- argument: Expression | null;
- delegate: boolean;
- }
Assignment Expression
- interface AssignmentExpression {
- type: 'AssignmentExpression';
- operator: '=' | '*=' | '**=' | '/=' | '%=' | '+=' | '-=' |
- '<<=' | '>>=' | '>>>=' | '&=' | '^=' | '|=';
- left: Expression;
- right: Expression;
- }
Sequence Expression
- interface SequenceExpression {
- type: 'SequenceExpression';
- expressions: Expression[];
- }