UNPKG

474 BTypeScriptView Raw
1/**
2 * Ask TS to re-check that `A1` extends `A2`.
3 * And if it fails, `A2` will be enforced anyway.
4 * Can also be used to add constraints on parameters.
5 * @param A1 to check against
6 * @param A2 to cast to
7 * @returns `A1 | A2`
8 * @example
9 * ```ts
10 * import {A} from 'ts-toolbelt'
11 *
12 * type test0 = A.Cast<'42', string> // '42'
13 * type test1 = A.Cast<'42', number> // number
14 * ```
15 */
16export declare type Cast<A1 extends any, A2 extends any> = A1 extends A2 ? A1 : A2;