-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.d.ts
46 lines (37 loc) · 1.26 KB
/
index.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
37
38
39
40
41
42
43
44
45
46
import { Big } from 'big.js';
import { Moment } from 'moment';
/**
* this makes all properties of T optional.
* also makes any properties with typeof Moment be Moment | string
* any properties with typeof Date be Date | string
* any properties with typeof boolean be boolean | 0 | 1
* any properties with typeof Big be Big | string
* all other properties keep their initial type
* See mapped and conditional types
*/
type GenPartial<T> = {
[P in keyof T]?: T[P] extends Moment ? Moment | string :
T[P] extends Date ? Date | string :
T[P] extends boolean ? boolean | 0 | 1 :
T[P];
}
interface BigTransformer {
from: (value: Big | string | number) => Big;
to: (value: Big) => string;
}
interface BooleanTransformer {
from: (value: boolean | 0 | 1) => boolean;
to: (value: boolean) => 0 | 1;
}
interface MomentTransformer {
from: (value: Moment | Date | string) => Moment;
to: (value: Moment) => string;
}
interface TimeTransformer {
from: (value: Moment | Date | string) => Moment;
to: (value: Moment) => string;
}
declare const bigTransformer: BigTransformer;
declare const booleanTransformer: BooleanTransformer;
declare const momentTransformer: MomentTransformer;
declare const timeTransformer: TimeTransformer;