File tree Expand file tree Collapse file tree 1 file changed +24
-11
lines changed Expand file tree Collapse file tree 1 file changed +24
-11
lines changed Original file line number Diff line number Diff line change 1
1
declare namespace json2csv {
2
- interface IField {
2
+ interface FieldValueCallback < T > {
3
+ ( row : T , field : string , data : string ) : string ;
4
+ }
5
+
6
+ interface FieldBase {
3
7
label ?: string ;
4
- value : string ;
5
8
default ?: string ;
6
9
}
7
10
8
- interface IOptions {
9
- data : any [ ] ;
10
- fields ?: ( string | IField ) [ ] ;
11
- filedNames ?: string [ ] ;
11
+ interface Field extends FieldBase {
12
+ value : string ;
13
+ }
14
+
15
+ interface CallbackField < T > extends FieldBase {
16
+ value : FieldValueCallback < T > ;
17
+ }
18
+
19
+ interface Options < T > {
20
+ data : T [ ] ;
21
+ fields ?: ( string | Field | CallbackField < T > ) [ ] ;
22
+ fieldNames ?: string [ ] ;
12
23
del ?: string ;
13
24
defaultValue ?: string ;
14
25
quotes ?: string ;
@@ -22,12 +33,14 @@ declare namespace json2csv {
22
33
includeEmptyRows ?: boolean ;
23
34
}
24
35
25
- interface ICallback {
36
+ interface Callback {
26
37
( error : Error , csv : string ) : void ;
27
38
}
28
-
29
- export function json2csv ( options : IOptions , callback : ICallback ) : void ;
30
- export function json2csv ( options : IOptions ) : string ;
31
39
}
32
40
33
- export = json2csv . json2csv ;
41
+ declare function json2csv < T > ( options : json2csv . Options < T > , callback : json2csv . Callback ) : void ;
42
+ declare function json2csv < T > ( options : json2csv . Options < T > ) : string ;
43
+ declare function json2csv ( options : json2csv . Options < { [ key : string ] : string ; } > , callback : json2csv . Callback ) : void ;
44
+ declare function json2csv ( options : json2csv . Options < { [ key : string ] : string ; } > ) : string ;
45
+
46
+ export = json2csv ;
You can’t perform that action at this time.
0 commit comments