mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-09-24 18:10:25 +00:00
Merge pull request #10794 from rictic/estree-async-await
Add async/await to ESTree's declarations.
This commit is contained in:
@@ -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<ESTree.Pattern> = functionDeclaration.params;
|
||||
blockStatement = functionDeclaration.body;
|
||||
booleanMaybe = functionDeclaration.generator;
|
||||
booleanMaybe = functionDeclaration.async;
|
||||
|
||||
var variableDeclaration: ESTree.VariableDeclaration;
|
||||
var declarations: Array<ESTree.VariableDeclarator> = 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;
|
||||
}
|
||||
|
||||
Vendored
+10
-2
@@ -63,11 +63,13 @@ export interface Program extends BaseNode {
|
||||
interface BaseFunction extends BaseNode {
|
||||
params: Array<Pattern>;
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user