Skip to content

Commit f9adb74

Browse files
committed
fix(types): make third and fourth params optional for findAllBy and findBy built queries
1 parent 53829b8 commit f9adb74

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

types/__tests__/type-tests.ts

+5
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ async function testQueryHelpers() {
8080
getByAutomationId(element, ['id', 'automationId'])
8181
findAllByAutomationId(element, 'id', {}, {timeout: 1000})
8282
findByAutomationId(element, 'id', {}, {timeout: 1000})
83+
// test optional params too
84+
findAllByAutomationId(element, 'id', {})
85+
findByAutomationId(element, 'id', {})
86+
findAllByAutomationId(element, 'id')
87+
findByAutomationId(element, 'id')
8388
}
8489

8590
async function testByRole() {

types/query-helpers.d.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Matcher, MatcherOptions } from './matches'
2-
import { waitForOptions } from './wait-for'
1+
import {Matcher, MatcherOptions} from './matches'
2+
import {waitForOptions} from './wait-for'
33

44
export interface SelectorMatcherOptions extends MatcherOptions {
55
selector?: string
@@ -39,12 +39,12 @@ export type GetAllBy<Arguments extends any[]> = QueryMethod<
3939
HTMLElement[]
4040
>
4141
export type FindAllBy<Arguments extends any[]> = QueryMethod<
42-
[Arguments[0], Arguments[1], waitForOptions],
42+
[Arguments[0], Arguments[1]?, waitForOptions?],
4343
Promise<HTMLElement[]>
4444
>
4545
export type GetBy<Arguments extends any[]> = QueryMethod<Arguments, HTMLElement>
4646
export type FindBy<Arguments extends any[]> = QueryMethod<
47-
[Arguments[0], Arguments[1], waitForOptions],
47+
[Arguments[0], Arguments[1]?, waitForOptions?],
4848
Promise<HTMLElement>
4949
>
5050

0 commit comments

Comments
 (0)