@@ -3,10 +3,12 @@ import prettyFormat from 'pretty-format';
33import { ErrorWithStack , prepareErrorMessage } from '../helpers/errors' ;
44import { createQueryByError } from '../helpers/errors' ;
55
6+ export type UnsafeProps = Record < string , unknown > ;
7+
68const UNSAFE_getByProps = (
79 instance : ReactTestInstance ,
8- ) : ( ( props : { [ propName : string ] : any } ) => ReactTestInstance ) =>
9- function getByPropsFn ( props : { [ propName : string ] : any } ) {
10+ ) : ( ( props : UnsafeProps ) => ReactTestInstance ) =>
11+ function getByPropsFn ( props : UnsafeProps ) {
1012 try {
1113 return instance . findByProps ( props ) ;
1214 } catch ( error ) {
@@ -16,8 +18,8 @@ const UNSAFE_getByProps = (
1618
1719const UNSAFE_getAllByProps = (
1820 instance : ReactTestInstance ,
19- ) : ( ( props : { [ propName : string ] : any } ) => Array < ReactTestInstance > ) =>
20- function getAllByPropsFn ( props : { [ propName : string ] : any } ) {
21+ ) : ( ( props : UnsafeProps ) => Array < ReactTestInstance > ) =>
22+ function getAllByPropsFn ( props : UnsafeProps ) {
2123 const results = instance . findAllByProps ( props ) ;
2224 if ( results . length === 0 ) {
2325 throw new ErrorWithStack (
@@ -30,8 +32,8 @@ const UNSAFE_getAllByProps = (
3032
3133const UNSAFE_queryByProps = (
3234 instance : ReactTestInstance ,
33- ) : ( ( props : { [ propName : string ] : any } ) => ReactTestInstance | null ) =>
34- function queryByPropsFn ( props : { [ propName : string ] : any } ) {
35+ ) : ( ( props : UnsafeProps ) => ReactTestInstance | null ) =>
36+ function queryByPropsFn ( props : UnsafeProps ) {
3537 try {
3638 return UNSAFE_getByProps ( instance ) ( props ) ;
3739 } catch ( error ) {
@@ -40,10 +42,8 @@ const UNSAFE_queryByProps = (
4042 } ;
4143
4244const UNSAFE_queryAllByProps =
43- (
44- instance : ReactTestInstance ,
45- ) : ( ( props : { [ propName : string ] : any } ) => Array < ReactTestInstance > ) =>
46- ( props : { [ propName : string ] : any } ) => {
45+ ( instance : ReactTestInstance ) : ( ( props : UnsafeProps ) => Array < ReactTestInstance > ) =>
46+ ( props : UnsafeProps ) => {
4747 try {
4848 return UNSAFE_getAllByProps ( instance ) ( props ) ;
4949 } catch {
@@ -53,10 +53,10 @@ const UNSAFE_queryAllByProps =
5353
5454// Unsafe aliases
5555export type UnsafeByPropsQueries = {
56- UNSAFE_getByProps : ( props : { [ key : string ] : any } ) => ReactTestInstance ;
57- UNSAFE_getAllByProps : ( props : { [ key : string ] : any } ) => Array < ReactTestInstance > ;
58- UNSAFE_queryByProps : ( props : { [ key : string ] : any } ) => ReactTestInstance | null ;
59- UNSAFE_queryAllByProps : ( props : { [ key : string ] : any } ) => Array < ReactTestInstance > ;
56+ UNSAFE_getByProps : ( props : UnsafeProps ) => ReactTestInstance ;
57+ UNSAFE_getAllByProps : ( props : UnsafeProps ) => Array < ReactTestInstance > ;
58+ UNSAFE_queryByProps : ( props : UnsafeProps ) => ReactTestInstance | null ;
59+ UNSAFE_queryAllByProps : ( props : UnsafeProps ) => Array < ReactTestInstance > ;
6060} ;
6161
6262// TODO: migrate to makeQueries pattern
0 commit comments