Skip to content

Commit f7364c5

Browse files
chore: explicitly coerce types in element commands
Typescript doesn't like accessing queries using a string variable since the queries object doesn't have an index type. This is currently ignored with a @ts-expect-error declaration. Instead ensure the queryName variable is treated as a key of the queries object.
1 parent f5dc2b3 commit f7364c5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ async function setupBrowser(browser: BrowserObject | MultiRemoteBrowserObject) {
136136
// add query to scoped to Element
137137
browser.addCommand(
138138
queryName,
139-
function(...args: any[]) {
140-
// @ts-expect-error
141-
return within(this as Element)[queryName](...args)
139+
function (...args: any[]) {
140+
const element = this as Element
141+
return within(element)[queryName as keyof typeof queries](...args)
142142
},
143143
true,
144144
)

0 commit comments

Comments
 (0)