Skip to content

Commit

Permalink
test(csv-stringify): columns type test as const
Browse files Browse the repository at this point in the history
  • Loading branch information
wdavidw committed Mar 15, 2024
1 parent 44f2e7c commit db53709
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/csv-stringify/dist/cjs/index.d.cts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> | ColumnOption[]
columns?: readonly string[] | PlainObject<string> | readonly ColumnOption[]
/**
* Set the field delimiter, one character only, defaults to a comma.
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/csv-stringify/dist/esm/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> | ColumnOption[]
columns?: readonly string[] | PlainObject<string> | readonly ColumnOption[]
/**
* Set the field delimiter, one character only, defaults to a comma.
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/csv-stringify/test/api.types.sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('API Types', () => {
const rd: RecordDelimiter | undefined = options.record_delimiter
const cast = options.cast
const castBoolean : Cast<boolean> | undefined = cast?.boolean
const columns: string[] | PlainObject<string> | ColumnOption[] | undefined = options.columns
const columns: readonly string[] | PlainObject<string> | readonly ColumnOption[] | undefined = options.columns
return [
rd, castBoolean, columns
]
Expand Down
7 changes: 7 additions & 0 deletions packages/csv-stringify/test/api.types.ts
Original file line number Diff line number Diff line change
@@ -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', () => {

Expand Down Expand Up @@ -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 = {}
Expand Down

0 comments on commit db53709

Please sign in to comment.