@@ -676,15 +676,8 @@ export default function convert(config: ConvertConfig): ESTreeNode | null {
676
676
677
677
case SyntaxKind . FunctionDeclaration : {
678
678
let functionDeclarationType = AST_NODE_TYPES . FunctionDeclaration ;
679
-
680
- if ( node . modifiers && node . modifiers . length ) {
681
- const isDeclareFunction = nodeUtils . hasModifier (
682
- SyntaxKind . DeclareKeyword ,
683
- node
684
- ) ;
685
- if ( isDeclareFunction ) {
686
- functionDeclarationType = AST_NODE_TYPES . DeclareFunction ;
687
- }
679
+ if ( nodeUtils . hasModifier ( SyntaxKind . DeclareKeyword , node ) ) {
680
+ functionDeclarationType = AST_NODE_TYPES . TSDeclareFunction ;
688
681
}
689
682
690
683
Object . assign ( result , {
@@ -694,14 +687,18 @@ export default function convert(config: ConvertConfig): ESTreeNode | null {
694
687
expression : false ,
695
688
async : nodeUtils . hasModifier ( SyntaxKind . AsyncKeyword , node ) ,
696
689
params : convertParameters ( ( node as any ) . parameters ) ,
697
- body : convertChild ( ( node as any ) . body )
690
+ body : convertChild ( ( node as any ) . body ) || undefined
698
691
} ) ;
699
692
700
693
// Process returnType
701
694
if ( ( node as any ) . type ) {
702
695
( result as any ) . returnType = convertTypeAnnotation ( ( node as any ) . type ) ;
703
696
}
704
697
698
+ if ( functionDeclarationType === AST_NODE_TYPES . TSDeclareFunction ) {
699
+ result . declare = true ;
700
+ }
701
+
705
702
// Process typeParameters
706
703
if ( ( node as any ) . typeParameters && ( node as any ) . typeParameters . length ) {
707
704
result . typeParameters = convertTSTypeParametersToTypeParametersDeclaration (
@@ -744,6 +741,10 @@ export default function convert(config: ConvertConfig): ESTreeNode | null {
744
741
kind : nodeUtils . getDeclarationKind ( ( node as any ) . declarationList )
745
742
} ) ;
746
743
744
+ if ( nodeUtils . hasModifier ( SyntaxKind . DeclareKeyword , node ) ) {
745
+ result . declare = true ;
746
+ }
747
+
747
748
// check for exports
748
749
result = nodeUtils . fixExports ( node , result as any , ast ) ;
749
750
break ;
@@ -1611,6 +1612,10 @@ export default function convert(config: ConvertConfig): ESTreeNode | null {
1611
1612
) ;
1612
1613
}
1613
1614
1615
+ if ( nodeUtils . hasModifier ( SyntaxKind . DeclareKeyword , node ) ) {
1616
+ result . declare = true ;
1617
+ }
1618
+
1614
1619
if ( node . decorators ) {
1615
1620
result . decorators = convertDecorators ( node . decorators ) ;
1616
1621
}
@@ -2421,10 +2426,6 @@ export default function convert(config: ConvertConfig): ESTreeNode | null {
2421
2426
}
2422
2427
2423
2428
const hasImplementsClause = interfaceHeritageClauses . length > 0 ;
2424
- const hasAbstractKeyword = nodeUtils . hasModifier (
2425
- SyntaxKind . AbstractKeyword ,
2426
- node
2427
- ) ;
2428
2429
const interfaceOpenBrace = nodeUtils . findNextToken (
2429
2430
interfaceLastClassToken ,
2430
2431
ast ,
@@ -2443,7 +2444,6 @@ export default function convert(config: ConvertConfig): ESTreeNode | null {
2443
2444
} ;
2444
2445
2445
2446
Object . assign ( result , {
2446
- abstract : hasAbstractKeyword ,
2447
2447
type : AST_NODE_TYPES . TSInterfaceDeclaration ,
2448
2448
body : interfaceBody ,
2449
2449
id : convertChild ( ( node as any ) . name ) ,
@@ -2461,6 +2461,12 @@ export default function convert(config: ConvertConfig): ESTreeNode | null {
2461
2461
if ( node . decorators ) {
2462
2462
result . decorators = convertDecorators ( node . decorators ) ;
2463
2463
}
2464
+ if ( nodeUtils . hasModifier ( SyntaxKind . AbstractKeyword , node ) ) {
2465
+ result . abstract = true ;
2466
+ }
2467
+ if ( nodeUtils . hasModifier ( SyntaxKind . DeclareKeyword , node ) ) {
2468
+ result . declare = true ;
2469
+ }
2464
2470
// check for exports
2465
2471
result = nodeUtils . fixExports ( node , result as any , ast ) ;
2466
2472
0 commit comments