File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -22,3 +22,41 @@ export const queryByAttribute: QueryByAttribute
22
22
export const queryAllByAttribute : AllByAttribute
23
23
export const debugDOM : ( htmlElement : HTMLElement ) => string
24
24
export const getElementError : ( message : string , container : HTMLElement ) => Error
25
+
26
+ /**
27
+ * query methods have a common call signature. Only the return type differs.
28
+ */
29
+ type QueryMethod < Arguments extends any [ ] , Return > = (
30
+ container : HTMLElement ,
31
+ ...args : Arguments
32
+ ) => Return
33
+ export type QueryBy < Arguments extends any [ ] > = QueryMethod <
34
+ Arguments ,
35
+ HTMLElement | null
36
+ >
37
+ export type GetAllBy < Arguments extends any [ ] > = QueryMethod <
38
+ Arguments ,
39
+ HTMLElement [ ]
40
+ >
41
+ export type FindAllBy < Arguments extends any [ ] > = QueryMethod <
42
+ Arguments ,
43
+ Promise < HTMLElement [ ] >
44
+ >
45
+ export type GetBy < Arguments extends any [ ] > = QueryMethod < Arguments , HTMLElement >
46
+ export type FindBy < Arguments extends any [ ] > = QueryMethod <
47
+ Arguments ,
48
+ Promise < HTMLElement >
49
+ >
50
+
51
+ export type BuiltQueryMethods < Arguments extends any [ ] > = [
52
+ QueryBy < Arguments > ,
53
+ GetAllBy < Arguments > ,
54
+ GetBy < Arguments > ,
55
+ FindAllBy < Arguments > ,
56
+ FindBy < Arguments >
57
+ ]
58
+ export const buildQueries : < Arguments extends any [ ] > (
59
+ queryByAll : GetAllBy < Arguments > ,
60
+ getMultipleError : ( container : HTMLElement , ...args : Arguments ) => string ,
61
+ getMissingError : ( container : HTMLElement , ...args : Arguments ) => string ,
62
+ ) => BuiltQueryMethods < Arguments >
You can’t perform that action at this time.
0 commit comments