UNPKG

1.27 kBTypeScriptView Raw
1import { Key } from './_Internal';
2import { NonNullable as UNonNullable } from '../Union/NonNullable';
3import { Depth } from '../Object/_Internal';
4import { BuiltIn } from '../Misc/BuiltIn';
5import { Cast } from '../Any/Cast';
6import { List } from './List';
7/**
8 * @hidden
9 */
10export declare type NonNullableFlat<O, K extends Key = Key> = {
11 [P in keyof O]: P extends K ? UNonNullable<O[P]> : O[P];
12} & {};
13/**
14 * @hidden
15 */
16declare type _NonNullableDeep<O> = {
17 [K in keyof O]: O[K] extends BuiltIn ? O[K] : NonNullableDeep<O[K], Key>;
18};
19/**
20 * @hidden
21 */
22export declare type NonNullableDeep<O, K extends Key = Key> = _NonNullableDeep<NonNullableFlat<O, K>>;
23/**
24 * @hidden
25 */
26export declare type NonNullablePart<O extends object, K extends Key, depth extends Depth> = {
27 'flat': NonNullableFlat<O, K>;
28 'deep': NonNullableDeep<O, K>;
29}[depth];
30/**
31 * Make some entries of `L` not nullable (deeply or not)
32 * @param L to make non nullable
33 * @param K (?=`Key`) to choose fields
34 * @param depth (?=`'flat'`) 'deep' to do it deeply
35 * @returns [[List]]
36 * @example
37 * ```ts
38 * ```
39 */
40export declare type NonNullable<L extends List, K extends Key = Key, depth extends Depth = 'flat'> = Cast<NonNullablePart<L, `${K & number}` | K, depth>, List>;
41export {};