adaltas / node-csv

Full featured CSV parser with simple api and tested against large datasets.
https://csv.js.org
MIT License
4.05k stars 267 forks source link

feat(ts): set `columns` type as `readonly` #358

Closed blemoine closed 7 months ago

blemoine commented 2 years ago

The goal is for stringify to support values declared as const.

eg.

const columns = ['name', 'age'] as const

stringify({columns})

As this array has no reasons to be mutated by stringify it's simpler to set it as readonly.

wdavidw commented 2 years ago

This is pretty much the case for every option. Not sure it provide much value.

blemoine commented 2 years ago

If you try the following code

const columns = ['name', 'age'] as const

stringify({columns})

without this PR patch, it won't compile - even though it's perfectly valid at runtime.

ViniciusLovato commented 1 year ago

Recently, I encountered the same problem. It would be helpful to support values declared as const.

wdavidw commented 1 year ago

Then I propose to update this PR to apply const to every option.

yoursunny commented 7 months ago

The Input type should be readonly too.