-
-
Notifications
You must be signed in to change notification settings - Fork 679
Expand file tree
/
Copy pathor-all.d.ts
More file actions
73 lines (51 loc) · 1.79 KB
/
or-all.d.ts
File metadata and controls
73 lines (51 loc) · 1.79 KB
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
73
import type {SomeExtend} from './some-extend.d.ts';
/**
Returns a boolean for whether any of the given elements is `true`.
Use-cases:
- Check if at least one condition in a list of booleans is met.
@example
```
import type {OrAll} from 'type-fest';
type FFT = OrAll<[false, false, true]>;
//=> true
type FFF = OrAll<[false, false, false]>;
//=> false
```
Note: When `boolean` is passed as an element, it is distributed into separate cases, and the final result is a union of those cases.
For example, `OrAll<[false, boolean]>` expands to `OrAll<[false, true]> | OrAll<[false, false]>`, which simplifies to `true | false` (i.e., `boolean`).
@example
```
import type {OrAll} from 'type-fest';
type A = OrAll<[false, boolean]>;
//=> boolean
type B = OrAll<[true, boolean]>;
//=> true
```
Note: If `never` is passed as an element, it is treated as `false` and the result is computed accordingly.
@example
```
import type {OrAll} from 'type-fest';
type A = OrAll<[never, never, true]>;
//=> true
type B = OrAll<[never, never, false]>;
//=> false
type C = OrAll<[never, never, never]>;
//=> false
type D = OrAll<[never, never, boolean]>;
//=> boolean
```
Note: If `any` is passed as an element, it is treated as `boolean` and the result is computed accordingly.
@example
```
import type {OrAll} from 'type-fest';
type A = OrAll<[false, any]>;
//=> boolean
type B = OrAll<[true, any]>;
//=> true
```
Note: `OrAll<[]>` evaluates to `false` because there are no `true` elements in an empty tuple. See [Wikipedia: Clause (logic) > Empty clauses](https://en.wikipedia.org/wiki/Clause_(logic)#Empty_clauses:~:text=The%20truth%20evaluation%20of%20an%20empty%20disjunctive%20clause%20is%20always%20false.).
@see {@link Or}
@see {@link AndAll}
*/
export type OrAll<T extends readonly boolean[]> = SomeExtend<T, true>;
export {};