Skip to content

Commit c88c915

Browse files
committed
Revert change to ByRoleMatcher type
1 parent 30d44d0 commit c88c915

File tree

3 files changed

+2
-6
lines changed

3 files changed

+2
-6
lines changed

src/queries/role.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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 ARIARoleDefinitionKey) ?? new Set()
245245
const implicitRoleSelectors = new Set(
246246
Array.from(roleRelations).map(({name}) => name),
247247
)

types/__tests__/type-tests.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,9 @@ export async function testByRole() {
182182
}) === null,
183183
)
184184

185-
// @ts-expect-error: allow to query for a role that isn't included in the types
186185
console.assert(queryByRole(element, 'foo') === null)
187-
// @ts-expect-error: allow to query for a role that isn't included in the types
188186
console.assert(queryByRole(element, /foo/) === null)
189-
// @ts-expect-error: allow to query for a role that isn't included in the types
190187
console.assert(screen.queryByRole('foo') === null)
191-
// @ts-expect-error: allow to query for a role that isn't included in the types
192188
console.assert(screen.queryByRole(/foo/) === null)
193189
}
194190

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)