@@ -326,15 +326,6 @@ module.exports = function convert(config) {
326
326
type : AST_NODE_TYPES . Identifier ,
327
327
name : nodeUtils . unescapeIdentifier ( node . text )
328
328
} ) ;
329
- if ( node . parent . questionToken && (
330
- SyntaxKind . Parameter === node . parent . kind ||
331
- SyntaxKind . PropertyDeclaration === node . parent . kind ||
332
- SyntaxKind . PropertySignature === node . parent . kind ||
333
- SyntaxKind . MethodDeclaration === node . parent . kind ||
334
- SyntaxKind . MethodSignature === node . parent . kind
335
- ) ) {
336
- result . optional = true ;
337
- }
338
329
break ;
339
330
340
331
case SyntaxKind . WithStatement :
@@ -675,6 +666,14 @@ module.exports = function convert(config) {
675
666
decorators : convertDecorators ( node . decorators ) ,
676
667
typeAnnotation : ( node . type ) ? convertTypeAnnotation ( node . type ) : null
677
668
} ) ;
669
+
670
+ if ( node . name . kind === SyntaxKind . Identifier && node . questionToken ) {
671
+ result . key . optional = true ;
672
+ }
673
+
674
+ if ( result . key . type === AST_NODE_TYPES . Literal && node . questionToken ) {
675
+ result . optional = true ;
676
+ }
678
677
break ;
679
678
}
680
679
@@ -753,6 +752,10 @@ module.exports = function convert(config) {
753
752
754
753
}
755
754
755
+ if ( result . key . type === AST_NODE_TYPES . Identifier && node . questionToken ) {
756
+ result . key . optional = true ;
757
+ }
758
+
756
759
if ( node . kind === SyntaxKind . GetAccessor ) {
757
760
result . kind = "get" ;
758
761
} else if ( node . kind === SyntaxKind . SetAccessor ) {
@@ -1097,6 +1100,10 @@ module.exports = function convert(config) {
1097
1100
} ) ;
1098
1101
}
1099
1102
1103
+ if ( node . questionToken ) {
1104
+ parameter . optional = true ;
1105
+ }
1106
+
1100
1107
if ( node . modifiers ) {
1101
1108
return {
1102
1109
type : AST_NODE_TYPES . TSParameterProperty ,
@@ -1764,6 +1771,15 @@ module.exports = function convert(config) {
1764
1771
} ) ;
1765
1772
break ;
1766
1773
1774
+ case SyntaxKind . PropertySignature :
1775
+ case SyntaxKind . MethodSignature :
1776
+ deeplyCopy ( ) ;
1777
+
1778
+ if ( node . questionToken ) {
1779
+ result . name . optional = true ;
1780
+ }
1781
+ break ;
1782
+
1767
1783
default :
1768
1784
deeplyCopy ( ) ;
1769
1785
}
0 commit comments