Skip to content

Commit d3cd3a0

Browse files
committed
fix: lint
1 parent 78a2f1b commit d3cd3a0

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

src/queries/role.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,13 @@ const queryAllByRole: AllByRole = (
124124
}
125125
}
126126

127-
const subtreeIsInaccessibleCache = new WeakMap()
128-
function cachedIsSubtreeInaccessible(element: Element) {
127+
const subtreeIsInaccessibleCache = new WeakMap<HTMLElement, Boolean>()
128+
function cachedIsSubtreeInaccessible(element: HTMLElement): Boolean {
129129
if (!subtreeIsInaccessibleCache.has(element)) {
130130
subtreeIsInaccessibleCache.set(element, isSubtreeInaccessible(element))
131131
}
132132

133-
return subtreeIsInaccessibleCache.get(element)
133+
return subtreeIsInaccessibleCache.get(element) as Boolean
134134
}
135135

136136
return Array.from(
@@ -143,7 +143,7 @@ const queryAllByRole: AllByRole = (
143143
const isRoleSpecifiedExplicitly = node.hasAttribute('role')
144144

145145
if (isRoleSpecifiedExplicitly) {
146-
const roleValue = node.getAttribute('role')!
146+
const roleValue = node.getAttribute('role') as string
147147
if (queryFallbacks) {
148148
return roleValue
149149
.split(' ')
@@ -222,7 +222,7 @@ const queryAllByRole: AllByRole = (
222222
.filter(element => {
223223
return hidden === false
224224
? isInaccessible(element, {
225-
isSubtreeInaccessible: cachedIsSubtreeInaccessible,
225+
isSubtreeInaccessible: cachedIsSubtreeInaccessible as any,
226226
}) === false
227227
: true
228228
})
@@ -241,7 +241,7 @@ function makeRoleSelector(
241241
const explicitRoleSelector =
242242
exact && !customNormalizer ? `*[role~="${role}"]` : '*[role]'
243243

244-
const roleRelations = roleElements.get(role as any) ?? new Set()
244+
const roleRelations = roleElements.get(role) ?? new Set()
245245
const implicitRoleSelectors = new Set(
246246
Array.from(roleRelations).map(({name}) => name),
247247
)
@@ -285,7 +285,7 @@ const getMissingError: GetErrorFunction<
285285
}
286286

287287
let roles = ''
288-
Array.from(container!.children).forEach(childElement => {
288+
Array.from((container as Element).children).forEach(childElement => {
289289
roles += prettyRoles(childElement, {
290290
hidden,
291291
includeDescription: description !== undefined,

src/query-helpers.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -213,16 +213,15 @@ 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: 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-
>,
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]>,
226225
) {
227226
const queryBy = wrapSingleQueryWithSuggestion(
228227
makeSingleQuery(queryAllBy, getMultipleError),
@@ -244,9 +243,11 @@ function buildQueries(
244243
)
245244

246245
const findAllBy = makeFindQuery(
246+
/* @ts-ignore */
247247
wrapAllByQueryWithSuggestion(getAllBy, queryAllBy.name, 'findAll'),
248248
)
249249
const findBy = makeFindQuery(
250+
/* @ts-ignore */
250251
wrapSingleQueryWithSuggestion(getBy, queryAllBy.name, 'find'),
251252
)
252253

types/matches.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export type Matcher = MatcherFunction | RegExp | number | string
88

99
// Get autocomplete for ARIARole union types, while still supporting another string
1010
// Ref: https://github.com/microsoft/TypeScript/issues/29729#issuecomment-505826972
11-
export type ByRoleMatcher = ARIARole | MatcherFunction | {}
11+
export type ByRoleMatcher = ARIARole | MatcherFunction
1212

1313
export type NormalizerFn = (text: string) => string
1414

0 commit comments

Comments
 (0)