@@ -494,23 +494,29 @@ function convertESNode0<N extends ESTree.Node>(
494
494
node : N | null | undefined ,
495
495
parent : any ,
496
496
ctx : Context ,
497
- extracted = new Set < ESTree . Node > ( ) ,
497
+ extracted = new Set < ESTree . Node | string > ( ) ,
498
498
) : N | null {
499
499
if ( ! node ) {
500
500
return null
501
501
}
502
502
if ( ! extracted . has ( node ) ) {
503
- EXTRACT_TOKENS [ node . type ] ?.( node , ctx , parent )
504
- for ( const comment of [
505
- ...( node . leadingComments || [ ] ) ,
506
- ...( ( node as any ) . innerComments || [ ] ) ,
507
- ...( node . trailingComments || [ ] ) ,
508
- ] ) {
509
- ctx . addComment ( {
510
- type : comment . type ,
511
- value : comment . value ,
512
- ...ctx . getConvertLocation ( getWithLoc ( comment ) ) ,
513
- } )
503
+ const key = `${ node . type } @[${ getWithLoc ( node ) . start } ,${
504
+ getWithLoc ( node ) . end
505
+ } ]`
506
+ if ( ! extracted . has ( key ) ) {
507
+ EXTRACT_TOKENS [ node . type ] ?.( node , ctx , parent )
508
+ for ( const comment of [
509
+ ...( node . leadingComments || [ ] ) ,
510
+ ...( ( node as any ) . innerComments || [ ] ) ,
511
+ ...( node . trailingComments || [ ] ) ,
512
+ ] ) {
513
+ ctx . addComment ( {
514
+ type : comment . type ,
515
+ value : comment . value ,
516
+ ...ctx . getConvertLocation ( getWithLoc ( comment ) ) ,
517
+ } )
518
+ }
519
+ extracted . add ( key )
514
520
}
515
521
extracted . add ( node )
516
522
}
0 commit comments