@@ -343,11 +343,10 @@ export default class Astx extends ExtendableProxy implements Iterable<Astx> {
343343 )
344344 }
345345
346- private _execPattern < Options , Return > (
346+ private _execPattern < Return > (
347347 name : string ,
348348 exec : (
349- pattern : NodePath < Node , any > | readonly NodePath < Node , any > [ ] ,
350- options ?: Options
349+ pattern : NodePath < Node , any > | readonly NodePath < Node , any > [ ]
351350 ) => Return ,
352351 arg0 :
353352 | string
@@ -358,31 +357,26 @@ export default class Astx extends ExtendableProxy implements Iterable<Astx> {
358357 | string [ ]
359358 | TemplateStringsArray ,
360359 ...rest : any [ ]
361- ) : Return | ( ( options ?: Options ) => Return ) {
360+ ) : Return {
362361 const { backend } = this
363362 const { parsePattern } = backend
364363 const { NodePath } = backend . t
365364 try {
366- let pattern : NodePath < Node , any > | readonly NodePath < Node , any > [ ] ,
367- options : Options | undefined
365+ let pattern : NodePath < Node , any > | readonly NodePath < Node , any > [ ]
368366 if ( typeof arg0 === 'string' ) {
369367 pattern = parsePattern ( arg0 )
370- options = rest [ 0 ]
371368 } else if (
372369 Array . isArray ( arg0 )
373370 ? arg0 [ 0 ] instanceof NodePath
374371 : arg0 instanceof NodePath
375372 ) {
376373 pattern = ensureArray ( arg0 as NodePath | NodePath [ ] )
377- options = rest [ 0 ]
378374 } else if ( isNode ( arg0 ) || isNodeArray ( arg0 ) ) {
379375 pattern = ensureArray ( arg0 ) . map ( ( node ) => new NodePath ( node ) )
380- options = rest [ 0 ]
381376 } else {
382377 pattern = parsePattern ( arg0 as any , ...rest )
383- return ( options ?: Options ) => exec ( pattern , options )
384378 }
385- return exec ( pattern , options )
379+ return exec ( pattern )
386380 } catch ( error ) {
387381 if ( error instanceof Error ) {
388382 CodeFrameError . rethrow ( error , {
@@ -394,9 +388,9 @@ export default class Astx extends ExtendableProxy implements Iterable<Astx> {
394388 }
395389 }
396390
397- private _execPatternOrPredicate < Options , Return > (
391+ private _execPatternOrPredicate < Return > (
398392 name : string ,
399- exec : ( match : CompiledMatcher [ 'match' ] , options ?: Options ) => Return ,
393+ exec : ( match : CompiledMatcher [ 'match' ] ) => Return ,
400394 arg0 :
401395 | string
402396 | Node
@@ -407,19 +401,18 @@ export default class Astx extends ExtendableProxy implements Iterable<Astx> {
407401 | TemplateStringsArray
408402 | FindPredicate ,
409403 ...rest : any [ ]
410- ) : Return | ( ( options ?: Options ) => Return ) {
404+ ) : Return {
411405 const { backend } = this
412406 if ( arg0 instanceof Function ) {
413407 const predicate = arg0
414- const options = rest [ 0 ]
415408 const match = ( path : NodePath ) : MatchResult => {
416409 const wrapper = new Astx ( this . context , [ path ] , {
417410 withCaptures : this . _matches ,
418411 } )
419412 return predicate ( wrapper ) ? wrapper . initialMatch || { } : null
420413 }
421414 try {
422- return exec ( match , options )
415+ return exec ( match )
423416 } catch ( error ) {
424417 if ( error instanceof Error ) {
425418 CodeFrameError . rethrow ( error , {
@@ -431,30 +424,23 @@ export default class Astx extends ExtendableProxy implements Iterable<Astx> {
431424 } else {
432425 return this . _execPattern (
433426 name ,
434- (
435- pattern : NodePath < Node , any > | readonly NodePath < Node , any > [ ] ,
436- options ?: Options
437- ) => {
427+ ( pattern : NodePath < Node , any > | readonly NodePath < Node , any > [ ] ) => {
438428 pattern = ensureArray ( pattern )
439429 if ( pattern . length !== 1 ) {
440430 throw new Error ( `must be a single node` )
441431 }
442432 const matcher = compileMatcher ( pattern [ 0 ] , {
443- ...options ,
444433 backend,
445434 } )
446- return exec ( matcher . match , options )
435+ return exec ( matcher . match )
447436 } ,
448437 arg0 ,
449438 ...rest
450439 )
451440 }
452441 }
453442
454- closest (
455- strings : TemplateStringsArray ,
456- ...quasis : any [ ]
457- ) : ( options ?: FindOptions ) => Astx
443+ closest ( strings : TemplateStringsArray , ...quasis : any [ ] ) : Astx
458444 closest (
459445 pattern :
460446 | string
@@ -475,7 +461,7 @@ export default class Astx extends ExtendableProxy implements Iterable<Astx> {
475461 | TemplateStringsArray
476462 | FindPredicate ,
477463 ...rest : any [ ]
478- ) : Astx | ( ( options ?: FindOptions ) => Astx ) {
464+ ) : Astx {
479465 const { context } = this
480466 return this . _execPatternOrPredicate (
481467 'closest' ,
@@ -500,10 +486,7 @@ export default class Astx extends ExtendableProxy implements Iterable<Astx> {
500486 )
501487 }
502488
503- destruct (
504- strings : TemplateStringsArray ,
505- ...quasis : any [ ]
506- ) : ( options ?: FindOptions ) => Astx
489+ destruct ( strings : TemplateStringsArray , ...quasis : any [ ] ) : Astx
507490 destruct (
508491 pattern :
509492 | string
@@ -524,7 +507,7 @@ export default class Astx extends ExtendableProxy implements Iterable<Astx> {
524507 | TemplateStringsArray
525508 | FindPredicate ,
526509 ...rest : any [ ]
527- ) : Astx | ( ( options ?: FindOptions ) => Astx ) {
510+ ) : Astx {
528511 const { context } = this
529512 return this . _execPatternOrPredicate (
530513 'destruct' ,
@@ -541,10 +524,7 @@ export default class Astx extends ExtendableProxy implements Iterable<Astx> {
541524 )
542525 }
543526
544- find (
545- strings : string [ ] | TemplateStringsArray ,
546- ...quasis : any [ ]
547- ) : ( options ?: FindOptions ) => Astx
527+ find ( strings : string [ ] | TemplateStringsArray , ...quasis : any [ ] ) : Astx
548528 find (
549529 pattern :
550530 | string
@@ -566,7 +546,7 @@ export default class Astx extends ExtendableProxy implements Iterable<Astx> {
566546 | TemplateStringsArray
567547 | FindPredicate ,
568548 ...rest : any [ ]
569- ) : Astx | ( ( options ?: FindOptions ) => Astx ) {
549+ ) : Astx {
570550 const { context, backend } = this
571551 if ( arg0 instanceof Function ) {
572552 const predicate = arg0
@@ -600,10 +580,7 @@ export default class Astx extends ExtendableProxy implements Iterable<Astx> {
600580 )
601581 }
602582
603- replace (
604- strings : string [ ] | TemplateStringsArray ,
605- ...quasis : any [ ]
606- ) : ( ) => void
583+ replace ( strings : string [ ] | TemplateStringsArray , ...quasis : any [ ] ) : void
607584 replace ( replacement : string | Node | Node [ ] | GetReplacement ) : void
608585 replace (
609586 arg0 :
@@ -614,7 +591,7 @@ export default class Astx extends ExtendableProxy implements Iterable<Astx> {
614591 | string [ ]
615592 | TemplateStringsArray ,
616593 ...quasis : any [ ]
617- ) : void | ( ( ) => void ) {
594+ ) : void {
618595 const { backend } = this
619596 const { parsePatternToNodes } = backend
620597 try {
@@ -643,7 +620,7 @@ export default class Astx extends ExtendableProxy implements Iterable<Astx> {
643620 }
644621 } else {
645622 const finalPaths = parsePatternToNodes ( arg0 , ...quasis )
646- return ( ) => this . replace ( finalPaths )
623+ this . replace ( finalPaths )
647624 }
648625 } catch ( error ) {
649626 if ( error instanceof Error ) {
@@ -660,10 +637,7 @@ export default class Astx extends ExtendableProxy implements Iterable<Astx> {
660637 this . replace ( [ ] )
661638 }
662639
663- addImports (
664- strings : string [ ] | TemplateStringsArray ,
665- ...quasis : any [ ]
666- ) : ( ) => Astx
640+ addImports ( strings : string [ ] | TemplateStringsArray , ...quasis : any [ ] ) : Astx
667641 addImports (
668642 pattern : string | Node | Node [ ] | NodePath < any > | NodePath < any > [ ]
669643 ) : Astx
@@ -677,7 +651,7 @@ export default class Astx extends ExtendableProxy implements Iterable<Astx> {
677651 | string [ ]
678652 | TemplateStringsArray ,
679653 ...rest : any [ ]
680- ) : Astx | ( ( ) => Astx ) {
654+ ) : Astx {
681655 return this . _execPattern (
682656 'addImports' ,
683657 ( pattern : NodePath < Node , any > | readonly NodePath < Node , any > [ ] ) : Astx =>
@@ -687,10 +661,7 @@ export default class Astx extends ExtendableProxy implements Iterable<Astx> {
687661 )
688662 }
689663
690- findImports (
691- strings : string [ ] | TemplateStringsArray ,
692- ...quasis : any [ ]
693- ) : ( ) => Astx
664+ findImports ( strings : string [ ] | TemplateStringsArray , ...quasis : any [ ] ) : Astx
694665 findImports (
695666 pattern : string | Node | Node [ ] | NodePath < any > | NodePath < any > [ ]
696667 ) : Astx
@@ -704,7 +675,7 @@ export default class Astx extends ExtendableProxy implements Iterable<Astx> {
704675 | string [ ]
705676 | TemplateStringsArray ,
706677 ...rest : any [ ]
707- ) : Astx | ( ( ) => Astx ) {
678+ ) : Astx {
708679 return this . _execPattern (
709680 'findImports' ,
710681 ( pattern : NodePath < Node , any > | readonly NodePath < Node , any > [ ] ) : Astx =>
@@ -717,7 +688,7 @@ export default class Astx extends ExtendableProxy implements Iterable<Astx> {
717688 removeImports (
718689 strings : string [ ] | TemplateStringsArray ,
719690 ...quasis : any [ ]
720- ) : ( ) => boolean
691+ ) : boolean
721692 removeImports (
722693 pattern : string | Node | Node [ ] | NodePath < any > | NodePath < any > [ ]
723694 ) : boolean
@@ -731,7 +702,7 @@ export default class Astx extends ExtendableProxy implements Iterable<Astx> {
731702 | string [ ]
732703 | TemplateStringsArray ,
733704 ...rest : any [ ]
734- ) : boolean | ( ( ) => boolean ) {
705+ ) : boolean {
735706 return this . _execPattern (
736707 'removeImports' ,
737708 (
@@ -746,7 +717,7 @@ export default class Astx extends ExtendableProxy implements Iterable<Astx> {
746717 replaceImport (
747718 strings : string [ ] | TemplateStringsArray ,
748719 ...quasis : any [ ]
749- ) : ( ) => ImportReplacer
720+ ) : ImportReplacer
750721 replaceImport (
751722 pattern : string | Node | Node [ ] | NodePath < any > | NodePath < any > [ ]
752723 ) : ImportReplacer
@@ -760,7 +731,7 @@ export default class Astx extends ExtendableProxy implements Iterable<Astx> {
760731 | string [ ]
761732 | TemplateStringsArray ,
762733 ...rest : any [ ]
763- ) : ImportReplacer | ( ( ) => ImportReplacer ) {
734+ ) : ImportReplacer {
764735 return this . _execPattern (
765736 'replaceImport' ,
766737 (
@@ -795,10 +766,7 @@ class ImportReplacer {
795766 public decl : ImportDeclaration
796767 ) { }
797768
798- with (
799- strings : string [ ] | TemplateStringsArray ,
800- ...quasis : any [ ]
801- ) : ( ) => boolean
769+ with ( strings : string [ ] | TemplateStringsArray , ...quasis : any [ ] ) : boolean
802770 with (
803771 pattern :
804772 | string
@@ -819,7 +787,7 @@ class ImportReplacer {
819787 | string [ ]
820788 | TemplateStringsArray ,
821789 ...rest : any [ ]
822- ) : boolean | ( ( ) => boolean ) {
790+ ) : boolean {
823791 const { backend } = this . astx
824792 const { parsePatternToNodes } = backend
825793
@@ -864,7 +832,7 @@ class ImportReplacer {
864832 return doReplace ( arg0 )
865833 } else {
866834 const rawReplacement = parsePatternToNodes ( arg0 as any , ...rest )
867- return ( ) => doReplace ( rawReplacement )
835+ return doReplace ( rawReplacement )
868836 }
869837 } catch ( error ) {
870838 if ( error instanceof Error ) {
0 commit comments