@@ -694,15 +694,8 @@ export default function convert(config: ConvertConfig): ESTreeNode | null {
694
694
695
695
case SyntaxKind . FunctionDeclaration : {
696
696
let functionDeclarationType = AST_NODE_TYPES . FunctionDeclaration ;
697
-
698
- if ( node . modifiers && node . modifiers . length ) {
699
- const isDeclareFunction = nodeUtils . hasModifier (
700
- SyntaxKind . DeclareKeyword ,
701
- node
702
- ) ;
703
- if ( isDeclareFunction ) {
704
- functionDeclarationType = AST_NODE_TYPES . DeclareFunction ;
705
- }
697
+ if ( nodeUtils . hasModifier ( SyntaxKind . DeclareKeyword , node ) ) {
698
+ functionDeclarationType = AST_NODE_TYPES . TSDeclareFunction ;
706
699
}
707
700
708
701
Object . assign ( result , {
@@ -712,14 +705,18 @@ export default function convert(config: ConvertConfig): ESTreeNode | null {
712
705
expression : false ,
713
706
async : nodeUtils . hasModifier ( SyntaxKind . AsyncKeyword , node ) ,
714
707
params : convertParameters ( node . parameters ) ,
715
- body : convertChild ( node . body )
708
+ body : convertChild ( node . body ) || undefined
716
709
} ) ;
717
710
718
711
// Process returnType
719
712
if ( node . type ) {
720
713
( result as any ) . returnType = convertTypeAnnotation ( node . type ) ;
721
714
}
722
715
716
+ if ( functionDeclarationType === AST_NODE_TYPES . TSDeclareFunction ) {
717
+ result . declare = true ;
718
+ }
719
+
723
720
// Process typeParameters
724
721
if ( node . typeParameters && node . typeParameters . length ) {
725
722
result . typeParameters = convertTSTypeParametersToTypeParametersDeclaration (
@@ -758,6 +755,10 @@ export default function convert(config: ConvertConfig): ESTreeNode | null {
758
755
kind : nodeUtils . getDeclarationKind ( node . declarationList )
759
756
} ) ;
760
757
758
+ if ( nodeUtils . hasModifier ( SyntaxKind . DeclareKeyword , node ) ) {
759
+ result . declare = true ;
760
+ }
761
+
761
762
// check for exports
762
763
result = nodeUtils . fixExports ( node , result as any , ast ) ;
763
764
break ;
@@ -1618,6 +1619,10 @@ export default function convert(config: ConvertConfig): ESTreeNode | null {
1618
1619
) ;
1619
1620
}
1620
1621
1622
+ if ( nodeUtils . hasModifier ( SyntaxKind . DeclareKeyword , node ) ) {
1623
+ result . declare = true ;
1624
+ }
1625
+
1621
1626
if ( node . decorators ) {
1622
1627
result . decorators = convertDecorators ( node . decorators ) ;
1623
1628
}
@@ -2400,10 +2405,6 @@ export default function convert(config: ConvertConfig): ESTreeNode | null {
2400
2405
}
2401
2406
2402
2407
const hasImplementsClause = interfaceHeritageClauses . length > 0 ;
2403
- const hasAbstractKeyword = nodeUtils . hasModifier (
2404
- SyntaxKind . AbstractKeyword ,
2405
- node
2406
- ) ;
2407
2408
const interfaceOpenBrace = nodeUtils . findNextToken (
2408
2409
interfaceLastClassToken ,
2409
2410
ast ,
@@ -2422,7 +2423,6 @@ export default function convert(config: ConvertConfig): ESTreeNode | null {
2422
2423
} ;
2423
2424
2424
2425
Object . assign ( result , {
2425
- abstract : hasAbstractKeyword ,
2426
2426
type : AST_NODE_TYPES . TSInterfaceDeclaration ,
2427
2427
body : interfaceBody ,
2428
2428
id : convertChild ( node . name ) ,
@@ -2440,6 +2440,12 @@ export default function convert(config: ConvertConfig): ESTreeNode | null {
2440
2440
if ( node . decorators ) {
2441
2441
result . decorators = convertDecorators ( node . decorators ) ;
2442
2442
}
2443
+ if ( nodeUtils . hasModifier ( SyntaxKind . AbstractKeyword , node ) ) {
2444
+ result . abstract = true ;
2445
+ }
2446
+ if ( nodeUtils . hasModifier ( SyntaxKind . DeclareKeyword , node ) ) {
2447
+ result . declare = true ;
2448
+ }
2443
2449
// check for exports
2444
2450
result = nodeUtils . fixExports ( node , result as any , ast ) ;
2445
2451
0 commit comments