diff --git a/estree/estree-tests.ts b/estree/estree-tests.ts index be9587f3c9..ebfb4efe57 100644 --- a/estree/estree-tests.ts +++ b/estree/estree-tests.ts @@ -84,6 +84,7 @@ declare var exportNamedDeclaration: ESTree.ExportNamedDeclaration; declare var exportSpecifier: ESTree.ExportSpecifier; declare var exportDefaultDeclaration: ESTree.ExportDefaultDeclaration; declare var exportAllDeclaration: ESTree.ExportAllDeclaration; +declare var awaitExpression: ESTree.AwaitExpression; declare var toplevelStatement: ESTree.Statement | ESTree.ModuleDeclaration; declare var expressionOrPattern: ESTree.Expression | ESTree.Pattern; @@ -181,6 +182,7 @@ pattern = assignmentPattern.left; expression = assignmentPattern.right; blockStatement = functionExpression.body; var booleanMaybe: boolean | undefined = functionExpression.generator; +booleanMaybe = functionExpression.async; // SequenceExpression var sequenceExpression: ESTree.SequenceExpression; @@ -224,6 +226,7 @@ identifier = functionDeclaration.id; var params: Array = functionDeclaration.params; blockStatement = functionDeclaration.body; booleanMaybe = functionDeclaration.generator; +booleanMaybe = functionDeclaration.async; var variableDeclaration: ESTree.VariableDeclaration; var declarations: Array = variableDeclaration.declarations; @@ -253,6 +256,9 @@ string = identifier.name; string = literal.type; any = literal.value; +// Await Expression +var awaitExpression: ESTree.AwaitExpression; +expression = awaitExpression.argument; // Test narrowing @@ -417,6 +423,9 @@ switch (node.type) { case 'Identifier': identifier = node; break; + case 'AwaitExpression': + awaitExpression = node; + break; // end narrowing of Expression case 'Property': @@ -637,6 +646,9 @@ switch (expression.type) { case 'Identifier': identifier = expression; break; + case 'AwaitExpression': + awaitExpression = expression; + break; default: never = expression; } diff --git a/estree/index.d.ts b/estree/index.d.ts index d086a6455d..26bccf1731 100644 --- a/estree/index.d.ts +++ b/estree/index.d.ts @@ -63,11 +63,13 @@ export interface Program extends BaseNode { interface BaseFunction extends BaseNode { params: Array; generator?: boolean; + async?: boolean; // The body is either BlockStatement or Expression because arrow functions // can have a body that's either. FunctionDeclarations and - // FunctionExpressions nave only BlockStatement bodies. + // FunctionExpressions have only BlockStatement bodies. body: BlockStatement | Expression; } + export type Function = FunctionDeclaration | FunctionExpression | ArrowFunctionExpression; @@ -208,7 +210,8 @@ type Expression = UpdateExpression | BinaryExpression | AssignmentExpression | LogicalExpression | MemberExpression | ConditionalExpression | CallExpression | NewExpression | SequenceExpression | TemplateLiteral | - TaggedTemplateExpression | ClassExpression | MetaProperty | Identifier; + TaggedTemplateExpression | ClassExpression | MetaProperty | Identifier | + AwaitExpression; export interface BaseExpression extends BaseNode { } export interface ThisExpression extends BaseExpression { @@ -526,3 +529,8 @@ export interface ExportAllDeclaration extends BaseModuleDeclaration { type: "ExportAllDeclaration"; source: Literal; } + +export interface AwaitExpression extends BaseExpression { + type: "AwaitExpression"; + argument: Expression; +}