adaltas / node-csv-parse

CSV parsing implementing the Node.js `stream.Transform` API

Home Page:https://csv.js.org/parse/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeScript types don't allow camelCase options

jgonera opened this issue · comments

Describe the bug

https://csv.js.org/parse/options/ states that you can use both underscore and camel case, but TypeScript types seem to only support underscore.

To Reproduce

import csvParse from 'csv-parse';

const csvParser = csvParse({
  delimiter: '|',
  fromLine: 2,
  toLine: -2,
  trim: true,
});

results in:

No overload matches this call.
  The last overload gave the following error.
    Argument of type '{ delimiter: string; fromLine: number; toLine: number; trim: boolean; }' is not assignable to parameter of type 'Callback'.
      Object literal may only specify known properties, and 'delimiter' does not exist in type 'Callback'.

Underscore is the default. I don't think it is necessary to port came case to typescript, it would be another thing to support in typescript which is already a lot of work that I have to maintain while not being typescript user. I'll rather add a line in the documentation to explain this.

Sure, that works too although it would be nice to be able to use camelCase which seems to be dominant in JS / TS. I suppose there are historical reasons for underscore being the default.

Not really, more a personnal choise. Iuse underscore for properties and function and camel case for method. If you fee like doing a pull request and update the api.types.ts test, I'll merge it.