UNPKG

695 BTypeScriptView Raw
1/**
2 * Check whether `A1` is part of `A2` or not. The difference with
3 * `extends` is that it forces a [[Boolean]] return.
4 * @param A1
5 * @param A2
6 * @returns [[Boolean]]
7 * @example
8 * ```ts
9 * import {A} from 'ts-toolbelt'
10 *
11 * type test0 = A.Extends<'a' | 'b', 'b'> // Boolean
12 * type test1 = A.Extends<'a', 'a' | 'b'> // True
13 *
14 * type test2 = A.Extends<{a: string}, {a: any}> // True
15 * type test3 = A.Extends<{a: any}, {a: any, b: any}> // False
16 *
17 * type test4 = A.Extends<never, never> // False
18 * /// Nothing cannot extend nothing, use `A.Equals`
19 * ```
20 */
21export declare type Extends<A1 extends any, A2 extends any> = [
22 A1
23] extends [never] ? 0 : A1 extends A2 ? 1 : 0;