Skip to content

Commit db53709

Browse files
committed
test(csv-stringify): columns type test as const
1 parent 44f2e7c commit db53709

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

packages/csv-stringify/dist/cjs/index.d.cts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export interface Options extends stream.TransformOptions {
6161
* can refer to nested properties of the input JSON
6262
* see the "header" option on how to print columns names on the first line
6363
*/
64-
columns?: string[] | PlainObject<string> | ColumnOption[]
64+
columns?: readonly string[] | PlainObject<string> | readonly ColumnOption[]
6565
/**
6666
* Set the field delimiter, one character only, defaults to a comma.
6767
*/

packages/csv-stringify/dist/esm/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export interface Options extends stream.TransformOptions {
6161
* can refer to nested properties of the input JSON
6262
* see the "header" option on how to print columns names on the first line
6363
*/
64-
columns?: string[] | PlainObject<string> | ColumnOption[]
64+
columns?: readonly string[] | PlainObject<string> | readonly ColumnOption[]
6565
/**
6666
* Set the field delimiter, one character only, defaults to a comma.
6767
*/

packages/csv-stringify/test/api.types.sync.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('API Types', () => {
2020
const rd: RecordDelimiter | undefined = options.record_delimiter
2121
const cast = options.cast
2222
const castBoolean : Cast<boolean> | undefined = cast?.boolean
23-
const columns: string[] | PlainObject<string> | ColumnOption[] | undefined = options.columns
23+
const columns: readonly string[] | PlainObject<string> | readonly ColumnOption[] | undefined = options.columns
2424
return [
2525
rd, castBoolean, columns
2626
]

packages/csv-stringify/test/api.types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
import 'should'
33
import { stringify, CastingContext, Options, Stringifier } from '../lib/index.js'
4+
import { stringify as stringifySync } from '../lib/index.js'
45

56
describe('API Types', () => {
67

@@ -74,6 +75,12 @@ describe('API Types', () => {
7475
field3: 'column3'
7576
}
7677
})
78+
79+
it("columns as const", () => {
80+
const options: Options = {};
81+
options.columns = ["b", "a"];
82+
options.columns = ["b", "a"] as const;
83+
});
7784

7885
it('delimiter', () => {
7986
const options: Options = {}

0 commit comments

Comments
 (0)