Bunlong / react-papaparse

react-papaparse is the fastest in-browser CSV (or delimited text) parser for React. It is full of useful features such as CSVReader, CSVDownloader, readString, jsonToCSV, readRemoteFile, ... etc.
https://react-papaparse.js.org
MIT License
364 stars 61 forks source link

Typescript ParseResult Type #97

Open thewordisbird opened 3 years ago

thewordisbird commented 3 years ago

With headers set to true in the config for the CSVReader component, the ParseResult type for the data doesn't match the provided output when the config prop has {header: true}. This is described in "The Parse Result Object" section of the docs:

data is an array of rows. If header is false, rows are arrays; otherwise they are objects of data keyed by the field name.

but is not addressed in the type definition as the ParseResult interface only provides a data type of T[] for the ParseResult Object data and has no option for the T type of the ParseResult Object data when header is true.

Bunlong commented 2 years ago

@thewordisbird It's was fixed. Please install the last version 3.18.0. Thanks!

gogog22510 commented 2 years ago

I still have this issue using 3.18.0. The return type complained by the compiler is still T[]. Any suggestion?