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

Add `columns` property in `Info` object type #390

Closed eliamaino-fp closed 1 year ago

eliamaino-fp commented 1 year ago

According to the documentation, the Info interface should include a columns property which returns a boolean if options.columns is false and an Array of normalized ColumnOption if options.columns is `true.

This should fix the following error when trying to access the columns property in the callback

Screenshot 2023-05-23 at 18 00 18
wdavidw commented 1 year ago

Thank you @eliamaino-fp, the column object contains either the name property or the disabled property set to true. Could you update you PR?

eliamaino-fp commented 1 year ago

@wdavidw do you mean something like this?

type Column = {
  name: string;
} | {
  disabled: true;
}
wdavidw commented 1 year ago

I should not write typescript but more something like readonly columns: boolean | { name: string }[] | { disabled: true }[]; if that is correct, or readonly columns: boolean | { name: string, disabled: true }[];