diff --git a/packages/csv-stringify/dist/cjs/index.d.cts b/packages/csv-stringify/dist/cjs/index.d.cts index 4c28ef9e..618b7ee6 100644 --- a/packages/csv-stringify/dist/cjs/index.d.cts +++ b/packages/csv-stringify/dist/cjs/index.d.cts @@ -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?: string[] | PlainObject | ColumnOption[] + columns?: readonly string[] | PlainObject | readonly ColumnOption[] /** * Set the field delimiter, one character only, defaults to a comma. */ diff --git a/packages/csv-stringify/dist/esm/index.d.ts b/packages/csv-stringify/dist/esm/index.d.ts index 4c28ef9e..618b7ee6 100644 --- a/packages/csv-stringify/dist/esm/index.d.ts +++ b/packages/csv-stringify/dist/esm/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?: string[] | PlainObject | ColumnOption[] + columns?: readonly string[] | PlainObject | readonly ColumnOption[] /** * 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 e2ba3761..07dc3c6b 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: string[] | PlainObject | ColumnOption[] | undefined = options.columns + const columns: readonly string[] | PlainObject | readonly ColumnOption[] | 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 2a11182c..9907e65e 100644 --- a/packages/csv-stringify/test/api.types.ts +++ b/packages/csv-stringify/test/api.types.ts @@ -1,6 +1,7 @@ import 'should' import { stringify, CastingContext, Options, Stringifier } from '../lib/index.js' +import { stringify as stringifySync } from '../lib/index.js' describe('API Types', () => { @@ -74,6 +75,12 @@ describe('API Types', () => { field3: 'column3' } }) + + it("columns as const", () => { + const options: Options = {}; + options.columns = ["b", "a"]; + options.columns = ["b", "a"] as const; + }); it('delimiter', () => { const options: Options = {}