@@ -105,6 +105,17 @@ function isESTreeClassMember(node) {
105
105
return node . kind !== SyntaxKind . SemicolonClassElement ;
106
106
}
107
107
108
+ /**
109
+ * Returns true if the given node is an async function
110
+ * @param {TSNode } node TypeScript AST node
111
+ * @returns {boolean } is an async function
112
+ */
113
+ function isAsyncFunction ( node ) {
114
+ return ! ! node . modifiers && ! ! node . modifiers . length && node . modifiers . some ( function ( modifier ) {
115
+ return modifier . kind === SyntaxKind . AsyncKeyword ;
116
+ } ) ;
117
+ }
118
+
108
119
/**
109
120
* Returns true if the given TSToken is a comma
110
121
* @param {TSToken } token the TypeScript token
@@ -852,6 +863,7 @@ module.exports = function(ast, extra) {
852
863
id : convertChild ( node . name ) ,
853
864
generator : ! ! node . asteriskToken ,
854
865
expression : false ,
866
+ async : isAsyncFunction ( node ) ,
855
867
params : node . parameters . map ( convertChild ) ,
856
868
body : convertChild ( node . body )
857
869
} ) ;
@@ -1057,6 +1069,7 @@ module.exports = function(ast, extra) {
1057
1069
id : null ,
1058
1070
generator : false ,
1059
1071
expression : false ,
1072
+ async : isAsyncFunction ( node ) ,
1060
1073
body : convertChild ( node . body ) ,
1061
1074
range : [ node . name . end , result . range [ 1 ] ] ,
1062
1075
loc : {
@@ -1158,6 +1171,7 @@ module.exports = function(ast, extra) {
1158
1171
} ) ,
1159
1172
generator : false ,
1160
1173
expression : false ,
1174
+ async : false ,
1161
1175
body : convertChild ( node . body ) ,
1162
1176
range : [ result . range [ 0 ] + constructorStartOffset , result . range [ 1 ] ] ,
1163
1177
loc : {
@@ -1226,6 +1240,7 @@ module.exports = function(ast, extra) {
1226
1240
generator : ! ! node . asteriskToken ,
1227
1241
params : node . parameters . map ( convertChild ) ,
1228
1242
body : convertChild ( node . body ) ,
1243
+ async : isAsyncFunction ( node ) ,
1229
1244
expression : false
1230
1245
} ) ;
1231
1246
// Process returnType
@@ -1308,6 +1323,7 @@ module.exports = function(ast, extra) {
1308
1323
id : null ,
1309
1324
params : node . parameters . map ( convertChild ) ,
1310
1325
body : convertChild ( node . body ) ,
1326
+ async : isAsyncFunction ( node ) ,
1311
1327
expression : node . body . kind !== SyntaxKind . Block
1312
1328
} ) ;
1313
1329
// Process returnType
@@ -1328,6 +1344,13 @@ module.exports = function(ast, extra) {
1328
1344
} ) ;
1329
1345
break ;
1330
1346
1347
+ case SyntaxKind . AwaitExpression :
1348
+ assign ( result , {
1349
+ type : "AwaitExpression" ,
1350
+ expression : convertChild ( node . expression )
1351
+ } ) ;
1352
+ break ;
1353
+
1331
1354
// Template Literals
1332
1355
1333
1356
case SyntaxKind . NoSubstitutionTemplateLiteral :
0 commit comments