1+ /* eslint-disable @typescript-eslint/no-implied-eval */
2+ /* eslint-disable no-new-func */
13import { ClientFunction , Selector } from "testcafe" ;
24import { Matcher , queries } from "@testing-library/dom" ;
35import type { Options , QueryName , WithinSelectors } from "./types" ;
@@ -27,6 +29,7 @@ const withinSelectors = queryNames.reduce((acc, withinQueryName) => {
2729 ) } .apply(null, args);
2830 ` ) ,
2931 } ;
32+ // eslint-disable-next-line
3033} , { } as Record < QueryName , ( node : Element , ...methodParams : any [ ] ) => any > ) ;
3134
3235export async function configureOnce ( options : Partial < Options > ) {
@@ -46,10 +49,13 @@ const withWithinMethods = (selector: Selector) => {
4649 returnDOMNodes : true ,
4750 } ) as unknown ) as WithinSelectors ;
4851} ;
52+ type SelectorArg =
53+ | string
54+ | Selector
55+ | SelectorPromise
56+ | ( ( ) => SelectorPromise ) ;
4957
50- export function within (
51- selector : string | Selector | SelectorPromise | ( ( ) => SelectorPromise )
52- ) : WithinSelectors {
58+ export function within ( selector : SelectorArg ) : WithinSelectors {
5359 if ( selector instanceof Function ) {
5460 return within ( selector ( ) ) ;
5561 }
@@ -65,7 +71,7 @@ export function within(
6571 }
6672}
6773
68- function isSelector ( sel : any ) : sel is Selector {
74+ function isSelector ( sel : SelectorArg ) : sel is Selector {
6975 return sel . constructor . name === SELECTOR_TYPE ;
7076}
7177
0 commit comments