1
- import {
2
- type AllByRole ,
3
- type ByRoleMatcher ,
4
- type ByRoleOptions ,
1
+ import {
5
2
type GetErrorFunction ,
6
3
type Matcher ,
7
4
type MatcherOptions ,
@@ -120,16 +117,16 @@ function makeGetAllQuery<Arguments extends unknown[]>(
120
117
121
118
// this accepts a getter query function and returns a function which calls
122
119
// waitFor and passing a function which invokes the getter.
123
- function makeFindQuery < QueryFor > (
120
+ function makeFindQuery < QueryFor , QueryMatcher > (
124
121
getter : (
125
122
container : HTMLElement ,
126
- text : Matcher ,
123
+ text : QueryMatcher ,
127
124
options : MatcherOptions ,
128
125
) => QueryFor ,
129
126
) {
130
127
return (
131
128
container : HTMLElement ,
132
- text : Matcher ,
129
+ text : QueryMatcher ,
133
130
options : MatcherOptions ,
134
131
waitForOptions : WaitForOptions ,
135
132
) => {
@@ -212,16 +209,17 @@ const wrapAllByQueryWithSuggestion =
212
209
// TODO: This deviates from the published declarations
213
210
// However, the implementation always required a dyadic (after `container`) not variadic `queryAllBy` considering the implementation of `makeFindQuery`
214
211
// This is at least statically true and can be verified by accepting `QueryMethod<Arguments, HTMLElement[]>`
215
- function buildQueries (
216
- queryAllBy :
217
- | AllByRole
218
- | QueryMethod < [ matcher : Matcher , options : MatcherOptions ] , HTMLElement [ ] > ,
219
- getMultipleError :
220
- | GetErrorFunction < [ matcher : ByRoleMatcher , options : ByRoleOptions ] >
221
- | GetErrorFunction < [ matcher : Matcher , options : MatcherOptions ] > ,
222
- getMissingError :
223
- | GetErrorFunction < [ matcher : ByRoleMatcher , options : ByRoleOptions ] >
224
- | GetErrorFunction < [ matcher : Matcher , options : MatcherOptions ] > ,
212
+ function buildQueries < QueryMatcher > (
213
+ queryAllBy : QueryMethod <
214
+ [ matcher : QueryMatcher , options : MatcherOptions ] ,
215
+ HTMLElement [ ]
216
+ > ,
217
+ getMultipleError : GetErrorFunction <
218
+ [ matcher : QueryMatcher , options : MatcherOptions ]
219
+ > ,
220
+ getMissingError : GetErrorFunction <
221
+ [ matcher : QueryMatcher , options : MatcherOptions ]
222
+ > ,
225
223
) {
226
224
const queryBy = wrapSingleQueryWithSuggestion (
227
225
makeSingleQuery ( queryAllBy , getMultipleError ) ,
@@ -243,11 +241,9 @@ function buildQueries(
243
241
)
244
242
245
243
const findAllBy = makeFindQuery (
246
- // @ts -expect-error: ByRoleMatcher and ByRoleOptions are not compatible with Matcher and MatcherOptions respectible
247
244
wrapAllByQueryWithSuggestion ( getAllBy , queryAllBy . name , 'findAll' ) ,
248
245
)
249
246
const findBy = makeFindQuery (
250
- // @ts -expect-error: ByRoleMatcher and ByRoleOptions are not compatible with Matcher and MatcherOptions respectible
251
247
wrapSingleQueryWithSuggestion ( getBy , queryAllBy . name , 'find' ) ,
252
248
)
253
249
0 commit comments