|
1 | 1 | import {getConfig} from '../config' |
2 | 2 | import {checkContainerType} from '../helpers' |
3 | 3 | import {getLabels, getRealLabels, getLabelContent} from '../label-helpers' |
4 | | -import {AllByText, GetErrorFunction} from '../../types' |
| 4 | +import { |
| 5 | + AllByText, |
| 6 | + GetErrorFunction, |
| 7 | + Matcher, |
| 8 | + MatcherOptions, |
| 9 | + SelectorMatcherOptions, |
| 10 | +} from '../../types' |
5 | 11 | import { |
6 | 12 | fuzzyMatches, |
7 | 13 | matches, |
@@ -100,9 +106,6 @@ const queryAllByLabelText: AllByText = ( |
100 | 106 | return labelledElements |
101 | 107 | }, []) |
102 | 108 | .concat( |
103 | | - // TODO: Remove ignore after `queryAllByAttribute` will be moved to TS |
104 | | - // eslint-disable-next-line @typescript-eslint/ban-ts-comment |
105 | | - // @ts-expect-error |
106 | 109 | queryAllByAttribute('aria-label', container, text, { |
107 | 110 | exact, |
108 | 111 | normalizer: matchNormalizer, |
@@ -171,42 +174,44 @@ function getTagNameOfElementAssociatedWithLabelViaFor( |
171 | 174 | } |
172 | 175 |
|
173 | 176 | // the reason mentioned above is the same reason we're not using buildQueries |
174 | | -const getMultipleError: GetErrorFunction = (c, text) => |
| 177 | +const getMultipleError: GetErrorFunction<[unknown]> = (c, text) => |
175 | 178 | `Found multiple elements with the text of: ${text}` |
176 | | -const queryByLabelText = wrapSingleQueryWithSuggestion( |
| 179 | +const queryByLabelText = wrapSingleQueryWithSuggestion< |
| 180 | + // @ts-expect-error -- See `wrapAllByQueryWithSuggestion` Argument constraint comment |
| 181 | + [labelText: Matcher, options?: SelectorMatcherOptions] |
| 182 | +>( |
177 | 183 | makeSingleQuery(queryAllByLabelText, getMultipleError), |
178 | 184 | queryAllByLabelText.name, |
179 | 185 | 'query', |
180 | 186 | ) |
181 | 187 | const getByLabelText = makeSingleQuery(getAllByLabelText, getMultipleError) |
182 | 188 |
|
183 | 189 | const findAllByLabelText = makeFindQuery( |
184 | | - wrapAllByQueryWithSuggestion( |
185 | | - getAllByLabelText, |
186 | | - getAllByLabelText.name, |
187 | | - 'findAll', |
188 | | - ), |
| 190 | + wrapAllByQueryWithSuggestion< |
| 191 | + // @ts-expect-error -- See `wrapAllByQueryWithSuggestion` Argument constraint comment |
| 192 | + [labelText: Matcher, options?: SelectorMatcherOptions] |
| 193 | + >(getAllByLabelText, getAllByLabelText.name, 'findAll'), |
189 | 194 | ) |
190 | 195 | const findByLabelText = makeFindQuery( |
191 | | - wrapSingleQueryWithSuggestion(getByLabelText, getAllByLabelText.name, 'find'), |
192 | | -) |
193 | | - |
194 | | -const getAllByLabelTextWithSuggestions = wrapAllByQueryWithSuggestion( |
195 | | - getAllByLabelText, |
196 | | - getAllByLabelText.name, |
197 | | - 'getAll', |
198 | | -) |
199 | | -const getByLabelTextWithSuggestions = wrapSingleQueryWithSuggestion( |
200 | | - getByLabelText, |
201 | | - getAllByLabelText.name, |
202 | | - 'get', |
| 196 | + wrapSingleQueryWithSuggestion< |
| 197 | + // @ts-expect-error -- See `wrapAllByQueryWithSuggestion` Argument constraint comment |
| 198 | + [labelText: Matcher, options?: SelectorMatcherOptions] |
| 199 | + >(getByLabelText, getAllByLabelText.name, 'find'), |
203 | 200 | ) |
204 | 201 |
|
205 | | -const queryAllByLabelTextWithSuggestions = wrapAllByQueryWithSuggestion( |
206 | | - queryAllByLabelText, |
207 | | - queryAllByLabelText.name, |
208 | | - 'queryAll', |
209 | | -) |
| 202 | +const getAllByLabelTextWithSuggestions = wrapAllByQueryWithSuggestion< |
| 203 | + // @ts-expect-error -- See `wrapAllByQueryWithSuggestion` Argument constraint comment |
| 204 | + [labelText: Matcher, options?: MatcherOptions] |
| 205 | +>(getAllByLabelText, getAllByLabelText.name, 'getAll') |
| 206 | +const getByLabelTextWithSuggestions = wrapSingleQueryWithSuggestion< |
| 207 | + // @ts-expect-error -- See `wrapAllByQueryWithSuggestion` Argument constraint comment |
| 208 | + [labelText: Matcher, options?: SelectorMatcherOptions] |
| 209 | +>(getByLabelText, getAllByLabelText.name, 'get') |
| 210 | + |
| 211 | +const queryAllByLabelTextWithSuggestions = wrapAllByQueryWithSuggestion< |
| 212 | + // @ts-expect-error -- See `wrapAllByQueryWithSuggestion` Argument constraint comment |
| 213 | + [labelText: Matcher, options?: SelectorMatcherOptions] |
| 214 | +>(queryAllByLabelText, queryAllByLabelText.name, 'queryAll') |
210 | 215 |
|
211 | 216 | export { |
212 | 217 | queryAllByLabelTextWithSuggestions as queryAllByLabelText, |
|
0 commit comments