Skip to content

Commit 7c90770

Browse files
alexkrolickKent C. Dodds
authored and
Kent C. Dodds
committed
fix(TS): fix types for bound attribute queries (#147)
closes #142 <!-- Thanks for your interest in the project. Bugs filed and PRs submitted are appreciated! Please make sure that you are familiar with and follow the Code of Conduct for this project (found in the CODE_OF_CONDUCT.md file). Also, please make sure you're familiar with and follow the instructions in the contributing guidelines (found in the CONTRIBUTING.md file). If you're new to contributing to open source projects, you might find this free video course helpful: http://kcd.im/pull-request Please fill out the information below to expedite the review and (hopefully) merge of your pull request! --> <!-- What changes are being made? (What feature/bug is being fixed here?) --> **What**: <!-- Why are these changes necessary? --> **Why**: <!-- How were these changes implemented? --> **How**: <!-- Have you done all of these things? --> **Checklist**: <!-- add "N/A" to the end of each line that's irrelevant to your changes --> <!-- to check an item, place an "x" in the box like so: "- [x] Documentation" --> - [ ] Documentation - [ ] Tests - [ ] Ready to be merged <!-- In your opinion, is this ready to be merged as soon as it's reviewed? --> - [ ] Added myself to contributors table <!-- this is optional, see the contributing guidelines for instructions --> <!-- feel free to add additional comments -->
1 parent 6821dc5 commit 7c90770

File tree

1 file changed

+41
-31
lines changed

1 file changed

+41
-31
lines changed

typings/queries.d.ts

+41-31
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
import {Matcher, MatcherOptions} from './matches'
22
import {
3-
QueryByAttribute,
4-
AllByAttribute,
53
SelectorMatcherOptions,
64
} from './query-helpers'
75

8-
export type GetByAttribute = (
6+
export type QueryByBoundAttribute = (
7+
container: HTMLElement,
8+
id: Matcher,
9+
options?: MatcherOptions,
10+
) => HTMLElement | null
11+
12+
export type AllByBoundAttribute = (
13+
container: HTMLElement,
14+
id: Matcher,
15+
options?: MatcherOptions,
16+
) => HTMLElement[]
17+
18+
export type GetByBoundAttribute = (
919
container: HTMLElement,
1020
id: Matcher,
1121
options?: MatcherOptions,
@@ -29,14 +39,14 @@ export type GetByText = (
2939
options?: SelectorMatcherOptions,
3040
) => HTMLElement
3141

32-
export const queryByPlaceholderText: QueryByAttribute
33-
export const queryAllByPlaceholderText: AllByAttribute
34-
export const getByPlaceholderText: GetByAttribute
35-
export const getAllByPlaceholderText: AllByAttribute
36-
export const queryBySelectText: QueryByAttribute
37-
export const queryAllBySelectText: AllByAttribute
38-
export const getBySelectText: GetByAttribute
39-
export const getAllBySelectText: AllByAttribute
42+
export const queryByPlaceholderText: QueryByBoundAttribute
43+
export const queryAllByPlaceholderText: AllByBoundAttribute
44+
export const getByPlaceholderText: GetByBoundAttribute
45+
export const getAllByPlaceholderText: AllByBoundAttribute
46+
export const queryBySelectText: QueryByBoundAttribute
47+
export const queryAllBySelectText: AllByBoundAttribute
48+
export const getBySelectText: GetByBoundAttribute
49+
export const getAllBySelectText: AllByBoundAttribute
4050
export const queryByText: QueryByText
4151
export const queryAllByText: AllByText
4252
export const getByText: GetByText
@@ -45,23 +55,23 @@ export const queryByLabelText: QueryByText
4555
export const queryAllByLabelText: AllByText
4656
export const getByLabelText: GetByText
4757
export const getAllByLabelText: AllByText
48-
export const queryByAltText: QueryByAttribute
49-
export const queryAllByAltText: AllByAttribute
50-
export const getByAltText: GetByAttribute
51-
export const getAllByAltText: AllByAttribute
52-
export const queryByTestId: QueryByAttribute
53-
export const queryAllByTestId: AllByAttribute
54-
export const getByTestId: GetByAttribute
55-
export const getAllByTestId: AllByAttribute
56-
export const queryByTitle: QueryByAttribute
57-
export const queryAllByTitle: AllByAttribute
58-
export const getByTitle: GetByAttribute
59-
export const getAllByTitle: AllByAttribute
60-
export const queryByValue: QueryByAttribute
61-
export const queryAllByValue: AllByAttribute
62-
export const getByValue: GetByAttribute
63-
export const getAllByValue: AllByAttribute
64-
export const queryByRole: QueryByAttribute
65-
export const queryAllByRole: AllByAttribute
66-
export const getByRole: GetByAttribute
67-
export const getAllByRole: AllByAttribute
58+
export const queryByAltText: QueryByBoundAttribute
59+
export const queryAllByAltText: AllByBoundAttribute
60+
export const getByAltText: GetByBoundAttribute
61+
export const getAllByAltText: AllByBoundAttribute
62+
export const queryByTestId: QueryByBoundAttribute
63+
export const queryAllByTestId: AllByBoundAttribute
64+
export const getByTestId: GetByBoundAttribute
65+
export const getAllByTestId: AllByBoundAttribute
66+
export const queryByTitle: QueryByBoundAttribute
67+
export const queryAllByTitle: AllByBoundAttribute
68+
export const getByTitle: GetByBoundAttribute
69+
export const getAllByTitle: AllByBoundAttribute
70+
export const queryByValue: QueryByBoundAttribute
71+
export const queryAllByValue: AllByBoundAttribute
72+
export const getByValue: GetByBoundAttribute
73+
export const getAllByValue: AllByBoundAttribute
74+
export const queryByRole: QueryByBoundAttribute
75+
export const queryAllByRole: AllByBoundAttribute
76+
export const getByRole: GetByBoundAttribute
77+
export const getAllByRole: AllByBoundAttribute

0 commit comments

Comments
 (0)