@@ -930,17 +930,26 @@ module.exports = function convert(config) {
930
930
} else {
931
931
return arrayItem ;
932
932
}
933
- } else {
933
+ } else if ( parent . kind === SyntaxKind . ObjectBindingPattern ) {
934
934
935
- Object . assign ( result , {
936
- type : AST_NODE_TYPES . Property ,
937
- key : convertChild ( node . propertyName || node . name ) ,
938
- value : convertChild ( node . name ) ,
939
- computed : false ,
940
- method : false ,
941
- shorthand : ! node . propertyName ,
942
- kind : "init"
943
- } ) ;
935
+ if ( node . dotDotDotToken ) {
936
+ Object . assign ( result , {
937
+ type : AST_NODE_TYPES . ExperimentalRestProperty ,
938
+ argument : convertChild ( node . propertyName || node . name ) ,
939
+ computed : Boolean ( node . propertyName && node . propertyName . kind === SyntaxKind . ComputedPropertyName ) ,
940
+ shorthand : ! node . propertyName
941
+ } ) ;
942
+ } else {
943
+ Object . assign ( result , {
944
+ type : AST_NODE_TYPES . Property ,
945
+ key : convertChild ( node . propertyName || node . name ) ,
946
+ value : convertChild ( node . name ) ,
947
+ computed : Boolean ( node . propertyName && node . propertyName . kind === SyntaxKind . ComputedPropertyName ) ,
948
+ method : false ,
949
+ shorthand : ! node . propertyName ,
950
+ kind : "init"
951
+ } ) ;
952
+ }
944
953
945
954
if ( node . initializer ) {
946
955
result . value = {
@@ -951,7 +960,6 @@ module.exports = function convert(config) {
951
960
loc : nodeUtils . getLocFor ( node . name . getStart ( ) , node . initializer . end , ast )
952
961
} ;
953
962
}
954
-
955
963
}
956
964
break ;
957
965
@@ -1053,12 +1061,30 @@ module.exports = function convert(config) {
1053
1061
// Patterns
1054
1062
1055
1063
case SyntaxKind . SpreadElement :
1056
- case SyntaxKind . SpreadAssignment :
1057
1064
Object . assign ( result , {
1058
1065
type : AST_NODE_TYPES . SpreadElement ,
1059
1066
argument : convertChild ( node . expression )
1060
1067
} ) ;
1061
1068
break ;
1069
+ case SyntaxKind . SpreadAssignment : {
1070
+ let type = AST_NODE_TYPES . ExperimentalSpreadProperty ;
1071
+
1072
+ if ( node . parent &&
1073
+ node . parent . parent . kind === SyntaxKind . BinaryExpression
1074
+ ) {
1075
+ if ( node . parent . parent . right === node . parent ) {
1076
+ type = AST_NODE_TYPES . ExperimentalSpreadProperty ;
1077
+ } else if ( node . parent . parent . left === node . parent ) {
1078
+ type = AST_NODE_TYPES . ExperimentalRestProperty ;
1079
+ }
1080
+ }
1081
+
1082
+ Object . assign ( result , {
1083
+ type,
1084
+ argument : convertChild ( node . expression )
1085
+ } ) ;
1086
+ break ;
1087
+ }
1062
1088
1063
1089
case SyntaxKind . Parameter : {
1064
1090
let parameter ;
0 commit comments