UNPKG

510 BTypeScriptView Raw
1import type {IsEqual} from './is-equal';
2
3/**
4Returns a boolean for whether two given types are both true.
5
6Use-case: Constructing complex conditional types where multiple conditions must be satisfied.
7
8@example
9```
10import type {And} from 'type-fest';
11
12And<true, true>;
13//=> true
14
15And<true, false>;
16//=> false
17```
18
19@see {@link Or}
20*/
21export type And<A extends boolean, B extends boolean> = [A, B][number] extends true
22 ? true
23 : true extends [IsEqual<A, false>, IsEqual<B, false>][number]
24 ? false
25 : never;