UNPKG

1.27 kBTypeScriptView Raw
1import { _Omit } from './Omit';
2import { _Pick } from './Pick';
3import { Key } from '../Any/Key';
4import { Strict } from '../Union/Strict';
5import { Boolean } from '../Boolean/_Internal';
6import { ComputeRaw } from '../Any/Compute';
7/**
8 * @hidden
9 */
10declare type __Either<O extends object, K extends Key> = _Omit<O, K> & ({
11 [P in K]: _Pick<O, P>;
12}[K]);
13/**
14 * @hidden
15 */
16declare type EitherStrict<O extends object, K extends Key> = Strict<__Either<O, K>>;
17/**
18 * @hidden
19 */
20declare type EitherLoose<O extends object, K extends Key> = ComputeRaw<__Either<O, K>>;
21/**
22 * @hidden
23 */
24export declare type _Either<O extends object, K extends Key, strict extends Boolean> = {
25 1: EitherStrict<O, K>;
26 0: EitherLoose<O, K>;
27}[strict];
28/**
29 * Split `O` into a [[Union]] with `K` keys in such a way that none of
30 * the keys are ever present with one another within the different unions.
31 * @param O to split
32 * @param K to split with
33 * @param strict (?=`1`) to force excess property checks https://github.com/microsoft/TypeScript/issues/20863
34 * @returns [[Object]] [[Union]]
35 * @example
36 * ```ts
37 * ```
38 */
39export declare type Either<O extends object, K extends Key, strict extends Boolean = 1> = O extends unknown ? _Either<O, K, strict> : never;
40export {};