-
Notifications
You must be signed in to change notification settings - Fork 0
/
where.ts
72 lines (62 loc) · 2.94 KB
/
where.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import * as ta from 'type-assertions'
import { WhereData, WhereFilterOp, WhereValue } from '../src'
type Object = {
s?: string
b?: boolean
n?: number
o?: { s?: string; n?: number }
ao?: { s?: string; n?: number }[]
an?: number[]
}
// assertions for WhereData
ta.assert<ta.Extends<{}, WhereData<Object>>>()
ta.assert<ta.Extends<{ s: string }, WhereData<Object>>>()
ta.assert<ta.Not<ta.Extends<{ s: boolean }, WhereData<Object>>>>()
ta.assert<ta.Extends<{ b: boolean }, WhereData<Object>>>()
ta.assert<ta.Extends<{ o: {} }, WhereData<Object>>>()
ta.assert<ta.Extends<{ an: [] }, WhereData<Object>>>()
ta.assert<ta.Extends<{ an: [2] }, WhereData<Object>>>()
// assertions WhereFilterOp for boolean
ta.assert<ta.Extends<'==', WhereFilterOp<boolean>>>()
ta.assert<ta.Extends<'in', WhereFilterOp<boolean>>>()
ta.assert<ta.Not<ta.Extends<'>=', WhereFilterOp<boolean>>>>()
ta.assert<ta.Not<ta.Extends<'array-contains', WhereFilterOp<boolean>>>>()
ta.assert<ta.Not<ta.Extends<'array-contains-any', WhereFilterOp<boolean>>>>()
// assertions WhereFilterOp for string
ta.assert<ta.Extends<'==', WhereFilterOp<string>>>()
ta.assert<ta.Extends<'in', WhereFilterOp<string>>>()
ta.assert<ta.Extends<'>=', WhereFilterOp<string>>>()
ta.assert<ta.Not<ta.Extends<'array-contains', WhereFilterOp<string>>>>()
ta.assert<ta.Not<ta.Extends<'array-contains-any', WhereFilterOp<string>>>>()
// assertions WhereFilterOp for Array<number>
ta.assert<ta.Extends<'==', WhereFilterOp<Array<number>>>>()
ta.assert<ta.Extends<'in', WhereFilterOp<Array<number>>>>()
ta.assert<ta.Not<ta.Extends<'>=', WhereFilterOp<Array<number>>>>>()
ta.assert<ta.Extends<'array-contains', WhereFilterOp<Array<number>>>>()
ta.assert<ta.Extends<'array-contains-any', WhereFilterOp<Array<number>>>>()
// assertions WhereValue ==
ta.assert<ta.Extends<boolean, WhereValue<boolean, '=='>>>()
ta.assert<ta.Extends<boolean[], WhereValue<boolean[], '=='>>>()
ta.assert<ta.Not<ta.Extends<boolean, WhereValue<boolean[], '=='>>>>()
ta.assert<ta.Not<ta.Extends<string, WhereValue<boolean, '=='>>>>()
// assertions WhereValue <
ta.assert<ta.Extends<string, WhereValue<string, '<'>>>()
ta.assert<ta.Not<ta.Extends<boolean, WhereValue<string, '<'>>>>()
// assertions WhereValue in
ta.assert<ta.Extends<string[], WhereValue<string, 'in'>>>()
ta.assert<ta.Not<ta.Extends<string, WhereValue<string, 'in'>>>>()
ta.assert<ta.Not<ta.Extends<number[], WhereValue<string, 'in'>>>>()
// assertions WhereValue array-contains
ta.assert<ta.Extends<string, WhereValue<string[], 'array-contains'>>>()
ta.assert<
ta.Not<ta.Extends<string[], WhereValue<string[], 'array-contains'>>>
>()
ta.assert<ta.Not<ta.Extends<number, WhereValue<string[], 'array-contains'>>>>()
// assertions WhereValue array-contains-any
ta.assert<ta.Extends<string[], WhereValue<string[], 'array-contains-any'>>>()
ta.assert<
ta.Not<ta.Extends<string, WhereValue<string[], 'array-contains-any'>>>
>()
ta.assert<
ta.Not<ta.Extends<number[], WhereValue<string[], 'array-contains-any'>>>
>()