main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
976 bytes
|
Line | |
---|
1 | import { Pick } from './Pick';
|
---|
2 | import { Depth } from './_Internal';
|
---|
3 | import { Key } from '../Any/Key';
|
---|
4 | import { PatchFlat } from './Patch';
|
---|
5 | import { Equals } from '../Any/Equals';
|
---|
6 | /**
|
---|
7 | * @hidden
|
---|
8 | */
|
---|
9 | export declare type OptionalFlat<O> = {
|
---|
10 | [K in keyof O]?: O[K];
|
---|
11 | } & {};
|
---|
12 | /**
|
---|
13 | * @hidden
|
---|
14 | */
|
---|
15 | export declare type OptionalDeep<O> = {
|
---|
16 | [K in keyof O]?: OptionalDeep<O[K]>;
|
---|
17 | };
|
---|
18 | /**
|
---|
19 | * @hidden
|
---|
20 | */
|
---|
21 | export declare type OptionalPart<O extends object, depth extends Depth> = {
|
---|
22 | 'flat': OptionalFlat<O>;
|
---|
23 | 'deep': OptionalDeep<O>;
|
---|
24 | }[depth];
|
---|
25 | /**
|
---|
26 | * Make some fields of `O` optional (deeply or not)
|
---|
27 | * @param O to make optional
|
---|
28 | * @param K (?=`Key`) to choose fields
|
---|
29 | * @param depth (?=`'flat'`) 'deep' to do it deeply
|
---|
30 | * @returns [[Object]]
|
---|
31 | * @example
|
---|
32 | * ```ts
|
---|
33 | * ```
|
---|
34 | */
|
---|
35 | export declare type Optional<O extends object, K extends Key = Key, depth extends Depth = 'flat'> = {
|
---|
36 | 1: OptionalPart<O, depth>;
|
---|
37 | 0: PatchFlat<OptionalPart<Pick<O, K>, depth>, O>;
|
---|
38 | }[Equals<Key, K>];
|
---|
Note:
See
TracBrowser
for help on using the repository browser.