fortana-co / react-dropzone-uploader

React file dropzone and uploader
https://react-dropzone-uploader.js.org/
MIT License
447 stars 183 forks source link

error with typescript #114

Open ck98-01 opened 4 years ago

ck98-01 commented 4 years ago

I don't know why it's giving me this error... can someone help?

TypeScript error in C:/Users/User/Desktop/dev/node_modules/react-dropzone-uploader/dist/Dropzone.tsx(635,7): Type 'Element[]' is not assignable to type 'null'. TS2322


    633 |     let previews = null
    634 |     if (PreviewComponent !== null) {
  > 635 |       previews = files.map(f => {

and :

TypeScript error in C:/Users/User/Desktop/dev/zidyia-frontend/node_modules/react-dropzone-uploader/dist/utils.ts(104,7): Type 'FileList' is not assignable to type 'null'. TS2322


    102 |     // NOTE: Only the 'drop' event has access to DataTransfer.files, otherwise it will always be empty        
    103 |     if ('files' in dt && dt.files.length) {
  > 104 |       items = dt.files
        |       ^
prmichaelsen commented 2 years ago

see https://github.com/fortana-co/react-dropzone-uploader/issues/108#issuecomment-1083621257

AminRafaey commented 1 year ago

That issue really took a lot of my time although behind the scene it wasn't a big one so i just create another package with ts issue fixes. Please have a look if anyone needs it. https://www.npmjs.com/package/react-dropzone-uploader-with-ts-issue-fixes Thank you!