diff --git a/types/json2csv/JSON2CSVBase.d.ts b/types/json2csv/JSON2CSVBase.d.ts index 165497b4c8..d65a3cc297 100644 --- a/types/json2csv/JSON2CSVBase.d.ts +++ b/types/json2csv/JSON2CSVBase.d.ts @@ -10,9 +10,9 @@ export declare namespace json2csv { } export interface Options { - fields?: (string | FieldInfo); + fields?: Array>; ndjson?: boolean; - unwind?: string | string[]; + unwind?: string | Array; flatten?: boolean; defaultValue?: string; quote?: string; diff --git a/types/json2csv/json2csv-tests.ts b/types/json2csv/json2csv-tests.ts index 566cc06cee..67c46cd1c3 100644 --- a/types/json2csv/json2csv-tests.ts +++ b/types/json2csv/json2csv-tests.ts @@ -17,9 +17,27 @@ parse({}); parse([]); parse({}, {}); +interface Car { + car: string; + price: number; +} + new Parser(); const parser: Parser = new Parser({}); s = parser.parse({ str: '', num: 1, obj: {} }); + +const opts: json2csv.Options = { + fields: [{ + label: 'Car Name', + value: 'car' + }, { + label: 'Price USD', + value: 'price' + }] +}; + +const json2csvParser = new Parser(opts); + parser.parse([]); const transform: Transform = new Transform({ quote: '' }); const nodeTransform: NodeTransform = transform;