/
index.ts
32 lines (26 loc) 路 949 Bytes
/
index.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
export * as Array from './array';
export * as Guard from './guard';
export * as Object from './object';
export * as String from './string';
export * as Function from './function';
export * as Tuple from './tuple';
export * as Expression from './expression';
export * from './json';
/**
* Get the type of a specific key `TKey` in `TValue`
*
* @example
*
* type X = Get<{ foo: 'bar', 'bar': 'foo' }, 'foo'>
* // 'bar'
*
* type X = Get<{ foo: 'bar', 'bar': 'foo' }, 'bar'>
* // 'foo'
*/
export type Get<TValue, TKey extends keyof TValue> = TValue[TKey];
export type PartialWithThis<T> = Partial<T> & ThisType<T>;
export type Without<TLeft, TRight> = { [key in Exclude<keyof TLeft, keyof TRight>]?: never };
export type XOR<TLeft, TRight> = TLeft | TRight extends object
? (Without<TLeft, TRight> & TRight) | (Without<TRight, TLeft> & TLeft)
: TLeft | TRight;
export type Cast<TValue, TType> = TValue extends TType ? TValue : never;