Skip to content

Commit dfc2474

Browse files
committed
fix: restore types
1 parent 1107419 commit dfc2474

File tree

3 files changed

+18
-19
lines changed

3 files changed

+18
-19
lines changed

src/queries/role.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
ByRoleMatcher,
2727
ByRoleOptions,
2828
GetErrorFunction,
29+
Matcher,
2930
MatcherFunction,
3031
MatcherOptions,
3132
NormalizerFn,
@@ -143,26 +144,25 @@ const queryAllByRole: AllByRole = (
143144

144145
if (isRoleSpecifiedExplicitly) {
145146
const roleValue = node.getAttribute('role')!
146-
/* istanbul ignore next */
147147
if (queryFallbacks) {
148148
return roleValue
149149
.split(' ')
150150
.filter(Boolean)
151-
.some(text => matcher(text, node, role, matchNormalizer))
151+
.some(text => matcher(text, node, role as Matcher, matchNormalizer))
152152
}
153153
// if a custom normalizer is passed then let normalizer handle the role value
154154
if (normalizer) {
155-
return matcher(roleValue, node, role, matchNormalizer)
155+
return matcher(roleValue, node, role as Matcher, matchNormalizer)
156156
}
157157
// other wise only send the first word to match
158158
const [firstWord] = roleValue.split(' ')
159-
return matcher(firstWord, node, role, matchNormalizer)
159+
return matcher(firstWord, node, role as Matcher, matchNormalizer)
160160
}
161161

162162
const implicitRoles = getImplicitAriaRoles(node)
163163

164164
return implicitRoles.some(implicitRole =>
165-
matcher(implicitRole, node, role, matchNormalizer),
165+
matcher(implicitRole, node, role as Matcher, matchNormalizer),
166166
)
167167
})
168168
.filter(element => {
@@ -215,7 +215,7 @@ const queryAllByRole: AllByRole = (
215215
getConfig().computedStyleSupportsPseudoElements,
216216
}),
217217
element,
218-
description,
218+
description as Matcher,
219219
text => text,
220220
)
221221
})
@@ -241,7 +241,7 @@ function makeRoleSelector(
241241
const explicitRoleSelector =
242242
exact && !customNormalizer ? `*[role~="${role}"]` : '*[role]'
243243

244-
const roleRelations = roleElements.get(role) ?? new Set()
244+
const roleRelations = roleElements.get(role as any) ?? new Set()
245245
const implicitRoleSelectors = new Set(
246246
Array.from(roleRelations).map(({name}) => name),
247247
)

src/query-helpers.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,16 @@ const wrapAllByQueryWithSuggestion =
213213
// However, the implementation always required a dyadic (after `container`) not variadic `queryAllBy` considering the implementation of `makeFindQuery`
214214
// This is at least statically true and can be verified by accepting `QueryMethod<Arguments, HTMLElement[]>`
215215
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]>,
216+
queryAllBy: QueryMethod<
217+
[matcher: Matcher, options: MatcherOptions],
218+
HTMLElement[]
219+
>,
220+
getMultipleError: GetErrorFunction<
221+
[matcher: Matcher, options: MatcherOptions]
222+
>,
223+
getMissingError: GetErrorFunction<
224+
[matcher: Matcher, options: MatcherOptions]
225+
>,
225226
) {
226227
const queryBy = wrapSingleQueryWithSuggestion(
227228
makeSingleQuery(queryAllBy, getMultipleError),
@@ -243,11 +244,9 @@ function buildQueries(
243244
)
244245

245246
const findAllBy = makeFindQuery(
246-
// @ts-expect-error -- See `wrapAllByQueryWithSuggestion` Argument constraint comment
247247
wrapAllByQueryWithSuggestion(getAllBy, queryAllBy.name, 'findAll'),
248248
)
249249
const findBy = makeFindQuery(
250-
// @ts-expect-error -- See `wrapAllByQueryWithSuggestion` Argument constraint comment
251250
wrapSingleQueryWithSuggestion(getBy, queryAllBy.name, 'find'),
252251
)
253252

types/queries.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export interface ByRoleOptions extends MatcherOptions {
126126
description?:
127127
| RegExp
128128
| string
129-
| ((accessibleName: string, element: Element) => boolean)
129+
| ((accessibleDescription: string, element: Element) => boolean)
130130
}
131131

132132
export type AllByRole<T extends HTMLElement = HTMLElement> = (

0 commit comments

Comments
 (0)