From f9adb74d1f4da76ec3de15625983222c40298b61 Mon Sep 17 00:00:00 2001 From: Chris Colborne Date: Tue, 20 Oct 2020 13:36:06 +1000 Subject: [PATCH] fix(types): make third and fourth params optional for findAllBy and findBy built queries --- types/__tests__/type-tests.ts | 5 +++++ types/query-helpers.d.ts | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/types/__tests__/type-tests.ts b/types/__tests__/type-tests.ts index 7a2fadfc..c6377b12 100644 --- a/types/__tests__/type-tests.ts +++ b/types/__tests__/type-tests.ts @@ -80,6 +80,11 @@ async function testQueryHelpers() { getByAutomationId(element, ['id', 'automationId']) findAllByAutomationId(element, 'id', {}, {timeout: 1000}) findByAutomationId(element, 'id', {}, {timeout: 1000}) + // test optional params too + findAllByAutomationId(element, 'id', {}) + findByAutomationId(element, 'id', {}) + findAllByAutomationId(element, 'id') + findByAutomationId(element, 'id') } async function testByRole() { diff --git a/types/query-helpers.d.ts b/types/query-helpers.d.ts index de50a2d3..26c80f19 100644 --- a/types/query-helpers.d.ts +++ b/types/query-helpers.d.ts @@ -1,5 +1,5 @@ -import { Matcher, MatcherOptions } from './matches' -import { waitForOptions } from './wait-for' +import {Matcher, MatcherOptions} from './matches' +import {waitForOptions} from './wait-for' export interface SelectorMatcherOptions extends MatcherOptions { selector?: string @@ -39,12 +39,12 @@ export type GetAllBy = QueryMethod< HTMLElement[] > export type FindAllBy = QueryMethod< - [Arguments[0], Arguments[1], waitForOptions], + [Arguments[0], Arguments[1]?, waitForOptions?], Promise > export type GetBy = QueryMethod export type FindBy = QueryMethod< - [Arguments[0], Arguments[1], waitForOptions], + [Arguments[0], Arguments[1]?, waitForOptions?], Promise >