nzambello / react-csv-reader

React component that handles csv file input and its parsing
https://nzambello.github.io/react-csv-reader/
MIT License
198 stars 47 forks source link

typescript definition are missing #37

Closed apoorvmote closed 4 years ago

apoorvmote commented 4 years ago

I chose this library over others because majority of the code is written in typescript. When I add this to my project it gives me error

Could not find a declaration file for module 'react-csv-reader'. '/home/apoorvmote/import-export/node_modules/react-csv-reader/dist/react-csv-reader.js' implicitly has an 'any' type.
  Try `npm install @types/react-csv-reader` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-csv-reader';`ts(7016)

To recreate

  1. npx create-react-app csv-test --use-npm --template typescript
  2. npm i react-csv-reader
  3. In App.tsx just add this line import CSVReader from 'react-csv-reader' then you get the error mentioned above.
adammesa commented 4 years ago

+1 Am also having this issue

nzambello commented 4 years ago

@apoorvmote @adammesa Fixed in v3.0.3 👍

apoorvmote commented 4 years ago

@nzambello I tested it and it works better now. If I had to be nitpicky then the parserOption is just any shape object. Which is better than before but it could be better.

nzambello commented 4 years ago

@nzambello I tested it and it works better now. If I had to be nitpicky then the parserOption is just any shape object. Which is better than before but it could be better.

@apoorvmote Thank you for pointing it to me, I'm a newbie on typescript libraries. Now typings provide full specifications for parserOptions, too. Updated in v3.0.4

adammesa commented 4 years ago

@nzambello you, sir, are fast!

Thank you for all your hard work. (I am 3 days new to TypeScript and had no idea how to tackle this)

apoorvmote commented 4 years ago

Thanks for fixing again quickly. I am also relatively new to Typescript. I just have 1 year experience with Typescript. I am not 3 days into Typescript.

If anyone else wanted strictly typed parserOption then first install npm i -D @types/papaparse only the types as dev dependancy. Then on the tsx file import { ParseConfig } from 'papaparse' this is type used for parserOption