@@ -282,28 +282,6 @@ export default function convert(config: ConvertConfig): ESTreeNode | null {
282
282
return classImplementsNode ;
283
283
}
284
284
285
- /**
286
- * Converts a ts.NodeArray of ts.Decorators into an array of ESTreeNode decorators
287
- * @param {ts.NodeArray<ts.Decorator> } decorators A ts.NodeArray of ts.Decorators to be converted
288
- * @returns {ESTreeNode[] } an array of converted ESTreeNode decorators
289
- */
290
- function convertDecorators (
291
- decorators : ts . NodeArray < ts . Decorator >
292
- ) : ESTreeNode [ ] {
293
- if ( ! decorators || ! decorators . length ) {
294
- return [ ] ;
295
- }
296
- return decorators . map ( decorator => {
297
- const expression = convertChild ( decorator . expression ) ;
298
- return {
299
- type : AST_NODE_TYPES . Decorator ,
300
- range : [ decorator . getStart ( ast ) , decorator . end ] ,
301
- loc : nodeUtils . getLoc ( decorator , ast ) ,
302
- expression
303
- } ;
304
- } ) ;
305
- }
306
-
307
285
/**
308
286
* Converts an array of ts.Node parameters into an array of ESTreeNode params
309
287
* @param {ts.Node[] } parameters An array of ts.Node params to be converted
@@ -319,7 +297,7 @@ export default function convert(config: ConvertConfig): ESTreeNode | null {
319
297
return convertedParam ;
320
298
}
321
299
return Object . assign ( convertedParam , {
322
- decorators : convertDecorators ( param . decorators )
300
+ decorators : param . decorators . map ( convertChild )
323
301
} ) ;
324
302
} ) ;
325
303
}
@@ -366,9 +344,8 @@ export default function convert(config: ConvertConfig): ESTreeNode | null {
366
344
)
367
345
: null ;
368
346
} else if ( key === 'decorators' ) {
369
- const decorators = convertDecorators ( ( node as any ) . decorators ) ;
370
- if ( decorators && decorators . length ) {
371
- result . decorators = decorators ;
347
+ if ( node . decorators && node . decorators . length ) {
348
+ result . decorators = node . decorators . map ( convertChild ) ;
372
349
}
373
350
} else {
374
351
if ( Array . isArray ( ( node as any ) [ key ] ) ) {
@@ -966,7 +943,7 @@ export default function convert(config: ConvertConfig): ESTreeNode | null {
966
943
}
967
944
968
945
if ( node . decorators ) {
969
- result . decorators = convertDecorators ( node . decorators ) ;
946
+ result . decorators = node . decorators . map ( convertChild ) ;
970
947
}
971
948
972
949
const accessibility = nodeUtils . getTSNodeAccessibility ( node ) ;
@@ -1071,7 +1048,7 @@ export default function convert(config: ConvertConfig): ESTreeNode | null {
1071
1048
} ) ;
1072
1049
1073
1050
if ( node . decorators ) {
1074
- result . decorators = convertDecorators ( node . decorators ) ;
1051
+ result . decorators = node . decorators . map ( convertChild ) ;
1075
1052
}
1076
1053
1077
1054
const accessibility = nodeUtils . getTSNodeAccessibility ( node ) ;
@@ -1631,7 +1608,7 @@ export default function convert(config: ConvertConfig): ESTreeNode | null {
1631
1608
}
1632
1609
1633
1610
if ( node . decorators ) {
1634
- result . decorators = convertDecorators ( node . decorators ) ;
1611
+ result . decorators = node . decorators . map ( convertChild ) ;
1635
1612
}
1636
1613
1637
1614
const filteredMembers = node . members . filter (
@@ -1979,6 +1956,14 @@ export default function convert(config: ConvertConfig): ESTreeNode | null {
1979
1956
break ;
1980
1957
}
1981
1958
1959
+ case SyntaxKind . Decorator : {
1960
+ Object . assign ( result , {
1961
+ type : AST_NODE_TYPES . Decorator ,
1962
+ expression : convertChild ( node . expression )
1963
+ } ) ;
1964
+ break ;
1965
+ }
1966
+
1982
1967
// Literals
1983
1968
1984
1969
case SyntaxKind . StringLiteral :
@@ -2550,7 +2535,7 @@ export default function convert(config: ConvertConfig): ESTreeNode | null {
2550
2535
* so we handle them here too.
2551
2536
*/
2552
2537
if ( node . decorators ) {
2553
- result . decorators = convertDecorators ( node . decorators ) ;
2538
+ result . decorators = node . decorators . map ( convertChild ) ;
2554
2539
}
2555
2540
if ( nodeUtils . hasModifier ( SyntaxKind . AbstractKeyword , node ) ) {
2556
2541
result . abstract = true ;
@@ -2605,7 +2590,7 @@ export default function convert(config: ConvertConfig): ESTreeNode | null {
2605
2590
* so we handle them here too.
2606
2591
*/
2607
2592
if ( node . decorators ) {
2608
- result . decorators = convertDecorators ( node . decorators ) ;
2593
+ result . decorators = node . decorators . map ( convertChild ) ;
2609
2594
}
2610
2595
break ;
2611
2596
}
0 commit comments