node-csv icon indicating copy to clipboard operation
node-csv copied to clipboard

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

Open blemoine opened this issue 2 years ago • 4 comments

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.

blemoine avatar Aug 16 '22 17:08 blemoine

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

wdavidw avatar Aug 16 '22 23:08 wdavidw

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.

blemoine avatar Aug 16 '22 23:08 blemoine

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

ViniciusLovato avatar Jan 30 '23 16:01 ViniciusLovato

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

wdavidw avatar Aug 25 '23 10:08 wdavidw

The Input type should be readonly too.

yoursunny avatar Mar 14 '24 14:03 yoursunny