File tree 1 file changed +8
-4
lines changed 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -509,30 +509,34 @@ export default class Generator {
509
509
} ) ;
510
510
511
511
const addArrowFunctionExpression = ( name : string , node : Node ) => {
512
- const { body, params } = node ;
512
+ const { body, params, async } = node ;
513
+ const fnKeyword = async ? 'async function' : 'function' ;
513
514
514
515
const paramString = params . length ?
515
516
`[✂${ params [ 0 ] . start } -${ params [ params . length - 1 ] . end } ✂]` :
516
517
`` ;
517
518
518
519
if ( body . type === 'BlockStatement' ) {
519
520
componentDefinition . addBlock ( deindent `
520
- function ${ name } (${ paramString } ) [✂${ body . start } -${ body . end } ✂]
521
+ ${ fnKeyword } ${ name } (${ paramString } ) [✂${ body . start } -${ body . end } ✂]
521
522
` ) ;
522
523
} else {
523
524
componentDefinition . addBlock ( deindent `
524
- function ${ name } (${ paramString } ) {
525
+ ${ fnKeyword } ${ name } (${ paramString } ) {
525
526
return [✂${ body . start } -${ body . end } ✂];
526
527
}
527
528
` ) ;
528
529
}
529
530
} ;
530
531
531
532
const addFunctionExpression = ( name : string , node : Node ) => {
533
+ const { async } = node ;
534
+ const fnKeyword = async ? 'async function' : 'function' ;
535
+
532
536
let c = node . start ;
533
537
while ( this . source [ c ] !== '(' ) c += 1 ;
534
538
componentDefinition . addBlock ( deindent `
535
- function ${ name } [✂${ c } -${ node . end } ✂];
539
+ ${ fnKeyword } ${ name } [✂${ c } -${ node . end } ✂];
536
540
` ) ;
537
541
} ;
538
542
You can’t perform that action at this time.
0 commit comments