@@ -618,7 +618,7 @@ module.exports = function convert(config) {
618
618
type : AST_NODE_TYPES . Property ,
619
619
key : convertChild ( node . name ) ,
620
620
value : convertChild ( node . initializer ) ,
621
- computed : ( node . name . kind === SyntaxKind . ComputedPropertyName ) ,
621
+ computed : nodeUtils . isComputedProperty ( node . name ) ,
622
622
method : false ,
623
623
shorthand : false ,
624
624
kind : "init"
@@ -660,7 +660,7 @@ module.exports = function convert(config) {
660
660
type : ( isAbstract ) ? AST_NODE_TYPES . TSAbstractClassProperty : AST_NODE_TYPES . ClassProperty ,
661
661
key : convertChild ( node . name ) ,
662
662
value : convertChild ( node . initializer ) ,
663
- computed : ( node . name . kind === SyntaxKind . ComputedPropertyName ) ,
663
+ computed : nodeUtils . isComputedProperty ( node . name ) ,
664
664
static : nodeUtils . hasStaticModifierFlag ( node ) ,
665
665
accessibility : nodeUtils . getTSNodeAccessibility ( node ) ,
666
666
decorators : convertDecorators ( node . decorators ) ,
@@ -713,7 +713,7 @@ module.exports = function convert(config) {
713
713
type : AST_NODE_TYPES . Property ,
714
714
key : convertChild ( node . name ) ,
715
715
value : method ,
716
- computed : ( node . name . kind === SyntaxKind . ComputedPropertyName ) ,
716
+ computed : nodeUtils . isComputedProperty ( node . name ) ,
717
717
method : nodeIsMethod ,
718
718
shorthand : false ,
719
719
kind : "init"
@@ -730,8 +730,6 @@ module.exports = function convert(config) {
730
730
return convertedParam ;
731
731
} ) ;
732
732
733
- const isMethodNameComputed = ( node . name . kind === SyntaxKind . ComputedPropertyName ) ;
734
-
735
733
/**
736
734
* TypeScript class methods can be defined as "abstract"
737
735
*/
@@ -743,7 +741,7 @@ module.exports = function convert(config) {
743
741
type : methodDefinitionType ,
744
742
key : convertChild ( node . name ) ,
745
743
value : method ,
746
- computed : isMethodNameComputed ,
744
+ computed : nodeUtils . isComputedProperty ( node . name ) ,
747
745
static : nodeUtils . hasStaticModifierFlag ( node ) ,
748
746
kind : "method" ,
749
747
accessibility : nodeUtils . getTSNodeAccessibility ( node ) ,
@@ -805,7 +803,7 @@ module.exports = function convert(config) {
805
803
} ;
806
804
807
805
const constructorIdentifierLoc = ast . getLineAndCharacterOfPosition ( firstConstructorToken . getStart ( ) ) ,
808
- constructorIsComputed = ! ! node . name && ( node . name . kind === SyntaxKind . ComputedPropertyName ) ;
806
+ constructorIsComputed = ! ! node . name && nodeUtils . isComputedProperty ( node . name ) ;
809
807
810
808
let constructorKey ;
811
809
@@ -1723,6 +1721,72 @@ module.exports = function convert(config) {
1723
1721
1724
1722
}
1725
1723
1724
+ case SyntaxKind . MethodSignature : {
1725
+ Object . assign ( result , {
1726
+ type : AST_NODE_TYPES . TSMethodSignature ,
1727
+ optional : nodeUtils . isOptional ( node ) ,
1728
+ computed : nodeUtils . isComputedProperty ( node . name ) ,
1729
+ key : convertChild ( node . name ) ,
1730
+ params : node . parameters . map ( parameter => convertChild ( parameter ) ) ,
1731
+ typeAnnotation : ( node . type ) ? convertTypeAnnotation ( node . type ) : null ,
1732
+ accessibility : nodeUtils . getTSNodeAccessibility ( node ) ,
1733
+ readonly : nodeUtils . hasModifier ( SyntaxKind . ReadonlyKeyword , node ) ,
1734
+ static : nodeUtils . hasModifier ( SyntaxKind . StaticKeyword , node ) ,
1735
+ export : nodeUtils . hasModifier ( SyntaxKind . ExportKeyword , node )
1736
+ } ) ;
1737
+
1738
+ if ( node . typeParameters ) {
1739
+ result . typeParameters = convertTSTypeParametersToTypeParametersDeclaration ( node . typeParameters ) ;
1740
+ }
1741
+
1742
+ break ;
1743
+ }
1744
+
1745
+ case SyntaxKind . PropertySignature : {
1746
+ Object . assign ( result , {
1747
+ type : AST_NODE_TYPES . TSPropertySignature ,
1748
+ optional : nodeUtils . isOptional ( node ) ,
1749
+ computed : nodeUtils . isComputedProperty ( node . name ) ,
1750
+ key : convertChild ( node . name ) ,
1751
+ typeAnnotation : ( node . type ) ? convertTypeAnnotation ( node . type ) : null ,
1752
+ initializer : convertChild ( node . initializer ) ,
1753
+ accessibility : nodeUtils . getTSNodeAccessibility ( node ) ,
1754
+ readonly : nodeUtils . hasModifier ( SyntaxKind . ReadonlyKeyword , node ) ,
1755
+ static : nodeUtils . hasModifier ( SyntaxKind . StaticKeyword , node ) ,
1756
+ export : nodeUtils . hasModifier ( SyntaxKind . ExportKeyword , node )
1757
+ } ) ;
1758
+
1759
+ break ;
1760
+ }
1761
+
1762
+ case SyntaxKind . IndexSignature : {
1763
+ Object . assign ( result , {
1764
+ type : AST_NODE_TYPES . TSIndexSignature ,
1765
+ index : convertChild ( node . parameters [ 0 ] ) ,
1766
+ typeAnnotation : ( node . type ) ? convertTypeAnnotation ( node . type ) : null ,
1767
+ accessibility : nodeUtils . getTSNodeAccessibility ( node ) ,
1768
+ readonly : nodeUtils . hasModifier ( SyntaxKind . ReadonlyKeyword , node ) ,
1769
+ static : nodeUtils . hasModifier ( SyntaxKind . StaticKeyword , node ) ,
1770
+ export : nodeUtils . hasModifier ( SyntaxKind . ExportKeyword , node )
1771
+ } ) ;
1772
+
1773
+ break ;
1774
+ }
1775
+
1776
+ case SyntaxKind . ConstructSignature : {
1777
+ Object . assign ( result , {
1778
+ type : AST_NODE_TYPES . TSConstructSignature ,
1779
+ params : node . parameters . map ( parameter => convertChild ( parameter ) ) ,
1780
+ typeAnnotation : ( node . type ) ? convertTypeAnnotation ( node . type ) : null
1781
+ } ) ;
1782
+
1783
+ if ( node . typeParameters ) {
1784
+ result . typeParameters = convertTSTypeParametersToTypeParametersDeclaration ( node . typeParameters ) ;
1785
+ }
1786
+
1787
+ break ;
1788
+ }
1789
+
1726
1790
case SyntaxKind . InterfaceDeclaration : {
1727
1791
const interfaceHeritageClauses = node . heritageClauses || [ ] ;
1728
1792
@@ -1771,15 +1835,6 @@ module.exports = function convert(config) {
1771
1835
} ) ;
1772
1836
break ;
1773
1837
1774
- case SyntaxKind . PropertySignature :
1775
- case SyntaxKind . MethodSignature :
1776
- deeplyCopy ( ) ;
1777
-
1778
- if ( node . questionToken ) {
1779
- result . name . optional = true ;
1780
- }
1781
- break ;
1782
-
1783
1838
default :
1784
1839
deeplyCopy ( ) ;
1785
1840
}
0 commit comments