@@ -19,10 +19,10 @@ use super::{EmptyArray, Null};
1919#[ ast_meta]
2020#[ estree( raw_deser = "
2121 const pattern = DESER[BindingPatternKind](POS_OFFSET.kind);
22- /* IF_TS */
23- pattern.optional = DESER[bool](POS_OFFSET.optional);
24- pattern.typeAnnotation = DESER[Option<Box<TSTypeAnnotation>>](POS_OFFSET.type_annotation);
25- /* END_IF_TS */
22+ if (IS_TS) {
23+ pattern.optional = DESER[bool](POS_OFFSET.optional);
24+ pattern.typeAnnotation = DESER[Option<Box<TSTypeAnnotation>>](POS_OFFSET.type_annotation);
25+ }
2626 pattern
2727" ) ]
2828pub struct BindingPatternConverter < ' a , ' b > ( pub & ' b BindingPattern < ' a > ) ;
@@ -121,17 +121,15 @@ impl ESTree for CatchParameterConverter<'_, '_> {
121121 pos = uint32[(POS_OFFSET.rest) >> 2];
122122 params.push({
123123 type: 'RestElement',
124- /* IF_TS */
125- decorators: [],
126- /* END_IF_TS */
124+ ...(IS_TS && { decorators: [] }),
127125 argument: DESER[BindingPatternKind]( POS_OFFSET<BindingRestElement>.argument.kind ),
128- /* IF_TS */
129- optional: DESER[bool]( POS_OFFSET<BindingRestElement>.argument.optional ),
130- typeAnnotation: DESER[Option<Box<TSTypeAnnotation>>](
131- POS_OFFSET<BindingRestElement>.argument.type_annotation
132- ),
133- value: null,
134- /* END_IF_TS */
126+ ...(IS_TS && {
127+ optional: DESER[bool]( POS_OFFSET<BindingRestElement>.argument.optional ),
128+ typeAnnotation: DESER[Option<Box<TSTypeAnnotation>>](
129+ POS_OFFSET<BindingRestElement>.argument.type_annotation
130+ ),
131+ value: null,
132+ }),
135133 start: DESER[u32]( POS_OFFSET<BindingRestElement>.span.start ),
136134 end: DESER[u32]( POS_OFFSET<BindingRestElement>.span.end ),
137135 });
@@ -183,35 +181,33 @@ impl ESTree for FormalParametersRest<'_, '_> {
183181#[ estree(
184182 ts_type = "FormalParameter | TSParameterProperty" ,
185183 raw_deser = "
186- /* IF_JS */
187- DESER[BindingPatternKind](POS_OFFSET.pattern.kind)
188- /* END_IF_JS */
189-
190- /* IF_TS */
191- const accessibility = DESER[Option<TSAccessibility>](POS_OFFSET.accessibility),
192- readonly = DESER[bool](POS_OFFSET.readonly),
193- override = DESER[bool](POS_OFFSET.override);
194184 let param;
195- if (accessibility === null && !readonly && !override) {
196- param = DESER[BindingPatternKind](POS_OFFSET.pattern.kind);
197- param.decorators = DESER[Vec<Decorator>](POS_OFFSET.decorators);
198- param.optional = DESER[bool](POS_OFFSET.pattern.optional);
199- param.typeAnnotation = DESER[Option<Box<TSTypeAnnotation>>](POS_OFFSET.pattern.type_annotation);
185+ if (IS_TS) {
186+ const accessibility = DESER[Option<TSAccessibility>](POS_OFFSET.accessibility),
187+ readonly = DESER[bool](POS_OFFSET.readonly),
188+ override = DESER[bool](POS_OFFSET.override);
189+ if (accessibility === null && !readonly && !override) {
190+ param = DESER[BindingPatternKind](POS_OFFSET.pattern.kind);
191+ param.decorators = DESER[Vec<Decorator>](POS_OFFSET.decorators);
192+ param.optional = DESER[bool](POS_OFFSET.pattern.optional);
193+ param.typeAnnotation = DESER[Option<Box<TSTypeAnnotation>>](POS_OFFSET.pattern.type_annotation);
194+ } else {
195+ param = {
196+ type: 'TSParameterProperty',
197+ accessibility,
198+ decorators: DESER[Vec<Decorator>](POS_OFFSET.decorators),
199+ override,
200+ parameter: DESER[BindingPattern](POS_OFFSET.pattern),
201+ readonly,
202+ static: false,
203+ start: DESER[u32]( POS_OFFSET<BindingRestElement>.span.start ),
204+ end: DESER[u32]( POS_OFFSET<BindingRestElement>.span.end ),
205+ };
206+ }
200207 } else {
201- param = {
202- type: 'TSParameterProperty',
203- accessibility,
204- decorators: DESER[Vec<Decorator>](POS_OFFSET.decorators),
205- override,
206- parameter: DESER[BindingPattern](POS_OFFSET.pattern),
207- readonly,
208- static: false,
209- start: DESER[u32]( POS_OFFSET<BindingRestElement>.span.start ),
210- end: DESER[u32]( POS_OFFSET<BindingRestElement>.span.end ),
211- };
208+ param = DESER[BindingPatternKind](POS_OFFSET.pattern.kind);
212209 }
213210 param
214- /* END_IF_TS */
215211 "
216212) ]
217213pub struct FormalParameterConverter < ' a , ' b > ( pub & ' b FormalParameter < ' a > ) ;
@@ -255,10 +251,10 @@ impl ESTree for FormalParameterConverter<'_, '_> {
255251 ts_type = "ParamPattern[]" ,
256252 raw_deser = "
257253 const params = DESER[Box<FormalParameters>](POS_OFFSET.params);
258- /* IF_TS */
259- const thisParam = DESER[Option<Box<TSThisParameter>>](POS_OFFSET.this_param);
260- if (thisParam !== null) params.unshift(thisParam);
261- /* END_IF_TS */
254+ if (IS_TS) {
255+ const thisParam = DESER[Option<Box<TSThisParameter>>](POS_OFFSET.this_param);
256+ if (thisParam !== null) params.unshift(thisParam);
257+ }
262258 params
263259 "
264260) ]
@@ -411,15 +407,13 @@ impl ESTree for ArrowFunctionExpressionBody<'_> {
411407 ? keyCopy
412408 : {
413409 type: 'AssignmentPattern',
414- /* IF_TS */
415- decorators: [],
416- /* END_IF_TS */
410+ ...(IS_TS && { decorators: [] }),
417411 left: keyCopy,
418412 right: init,
419- /* IF_TS */
420- optional: false,
421- typeAnnotation: null,
422- /* END_IF_TS */
413+ ...(IS_TS && {
414+ optional: false,
415+ typeAnnotation: null,
416+ }),
423417 start: THIS.start,
424418 end: THIS.end,
425419 };
0 commit comments