From db537093e043e97eb19e0fa4c497bf842a6e2bbb Mon Sep 17 00:00:00 2001 From: David Worms Date: Fri, 15 Mar 2024 11:37:58 +0100 Subject: [PATCH] test(csv-stringify): columns type test as const --- packages/csv-stringify/dist/cjs/index.d.cts | 2 +- packages/csv-stringify/dist/esm/index.d.ts | 2 +- packages/csv-stringify/test/api.types.sync.ts | 2 +- packages/csv-stringify/test/api.types.ts | 7 +++++++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/csv-stringify/dist/cjs/index.d.cts b/packages/csv-stringify/dist/cjs/index.d.cts index 4c28ef9e4..618b7ee6b 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 4c28ef9e4..618b7ee6b 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 e2ba3761c..07dc3c6b3 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 2a11182c4..9907e65ef 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 = {}