generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 11
/
util.d.ts
36 lines (30 loc) · 972 Bytes
/
util.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/** @internal */
export type _TODO = any
/**
* https://stackoverflow.com/a/53229567
* @internal
*/
type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never }
/** @internal */
export type XOR<T, U> = (T | U) extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U
/**
* Object structure that exposes both array-like and object-like behaviour.
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect#iterable)
*/
export type IterableMap<T> = { [name: string]: T } & Iterable<T>
/**
* T is a tuple of alternating K, V pairs -> true, else false
* Allows for variadic parameter lists with alternating expecing types,
* like we have in cql.SELECT.where
*/
type KVPairs<T,K,V> = T extends []
? true
: T extends [K, V, ...infer R]
? KVPairs<R,K,V>
: false
/**
* Recursively excludes nullability from all properties of T.
*/
export type DeepRequired<T> = {
[K in keyof T]: DeepRequired<T[K]>
} & Exclude<Required<T>, null>