Inist-CNRS / node-csv-string

CSV Strings & Streams for Javascript since 2012
Other
86 stars 18 forks source link

[typescript] parse return type incorrect #40

Closed bgoyarts closed 4 years ago

bgoyarts commented 4 years ago

The return-type of parse seems incorrect.

The types are defined as follows:

  type rowElement = string | number | boolean;
  type row = rowElement[];

  function parse(input: string, separator?: separator, quote?: string): row;

However, parse returns an array of rows.

Currently I'm getting errors because I try to do the following :

    const header = parse(data)[0] 

If I console.log(header) I have received an array of strings. However header is now implicitly typed as rowElement which means typescript sees it as a string | number | boolean

You can check out an example here

touv commented 4 years ago

Do you have the same error with the new version 4.0.1

bgoyarts commented 4 years ago

Nope, that solves it. Thanks!