@@ -104,11 +104,20 @@ export function serialize_get_binding(node, state) {
104
104
}
105
105
106
106
/**
107
- * @param {import('estree').Expression } expression
107
+ * @param {import('estree').Expression | import('estree').Pattern } expression
108
108
* @returns {boolean }
109
109
*/
110
110
function is_async ( expression ) {
111
111
switch ( expression . type ) {
112
+ case 'ArrayPattern' : {
113
+ for ( const element of expression . elements ) {
114
+ if ( element && is_async ( element ) ) {
115
+ return true ;
116
+ }
117
+ }
118
+
119
+ return false ;
120
+ }
112
121
case 'ArrayExpression' : {
113
122
for ( const element of expression . elements ) {
114
123
if ( ! element ) {
@@ -130,6 +139,10 @@ function is_async(expression) {
130
139
case 'FunctionExpression' : {
131
140
return expression . async ?? false ;
132
141
}
142
+ case 'AssignmentPattern' :
143
+ case 'AssignmentExpression' : {
144
+ return is_async ( expression . left ) || is_async ( expression . right ) ;
145
+ }
133
146
case 'AwaitExpression' : {
134
147
return true ;
135
148
}
@@ -201,22 +214,21 @@ function is_async(expression) {
201
214
case 'MetaProperty' : {
202
215
return false ;
203
216
}
217
+ case 'ObjectPattern' :
204
218
case 'ObjectExpression' : {
205
219
for ( const property of expression . properties ) {
206
220
if ( property . type === 'SpreadElement' ) {
207
221
if ( is_async ( property . argument ) ) {
208
222
return true ;
209
223
}
210
- } else {
224
+ } else if ( property . type === 'Property' ) {
211
225
const key_is_async =
212
226
property . key . type === 'PrivateIdentifier' ? false : is_async ( property . key ) ;
213
227
if ( key_is_async ) {
214
228
return true ;
215
229
}
216
230
217
- const value_is_async = is_async (
218
- /** @type {import('estree').Expression } */ ( property . value )
219
- ) ;
231
+ const value_is_async = is_async ( property . value ) ;
220
232
if ( value_is_async ) {
221
233
return true ;
222
234
}
@@ -225,6 +237,9 @@ function is_async(expression) {
225
237
226
238
return false ;
227
239
}
240
+ case 'RestElement' : {
241
+ return is_async ( expression . argument ) ;
242
+ }
228
243
case 'SequenceExpression' : {
229
244
for ( const subexpression of expression . expressions ) {
230
245
if ( is_async ( subexpression ) ) {
0 commit comments