diff --git a/packages/csv-stringify/lib/index.d.ts b/packages/csv-stringify/lib/index.d.ts index 618b7ee6..d4328305 100644 --- a/packages/csv-stringify/lib/index.d.ts +++ b/packages/csv-stringify/lib/index.d.ts @@ -61,7 +61,7 @@ export interface Options extends stream.TransformOptions { * can refer to nested properties of the input JSON * see the "header" option on how to print columns names on the first line */ - columns?: readonly string[] | PlainObject | readonly ColumnOption[] + columns?: ReadonlyArray | PlainObject /** * Set the field delimiter, one character only, defaults to a comma. */ diff --git a/packages/csv-stringify/test/api.types.sync.ts b/packages/csv-stringify/test/api.types.sync.ts index 07dc3c6b..87cf315d 100644 --- a/packages/csv-stringify/test/api.types.sync.ts +++ b/packages/csv-stringify/test/api.types.sync.ts @@ -20,7 +20,7 @@ describe('API Types', () => { const rd: RecordDelimiter | undefined = options.record_delimiter const cast = options.cast const castBoolean : Cast | undefined = cast?.boolean - const columns: readonly string[] | PlainObject | readonly ColumnOption[] | undefined = options.columns + const columns: ReadonlyArray | PlainObject | undefined = options.columns return [ rd, castBoolean, columns ] diff --git a/packages/csv-stringify/test/api.types.ts b/packages/csv-stringify/test/api.types.ts index 9907e65e..8953bb08 100644 --- a/packages/csv-stringify/test/api.types.ts +++ b/packages/csv-stringify/test/api.types.ts @@ -70,6 +70,12 @@ describe('API Types', () => { { key: 'b' }, { key: 'a' } ] + options.columns = [ + { key: "b", header: "B" }, + { key: "a" , header: "A" }, + "c", + { key: "d" }, + ]; options.columns = { field1: 'column1', field3: 'column3' @@ -81,7 +87,7 @@ describe('API Types', () => { options.columns = ["b", "a"]; options.columns = ["b", "a"] as const; }); - + it('delimiter', () => { const options: Options = {} options.delimiter = ':'