Light and simple Reactjs drag and drop files library to use with very flexible options to change, so you put whatever the design you want for your drop-area. Users can drag and drop or even select the file anywhere in the window.
MIT License
248
stars
91
forks
source link
Narrow handle function types based on "multiple" prop #139
Hey! 👋🏼 Thanks a lot for implementing such a time-saver library!
When multiple prop is set to a falsy value, it is guaranteed to have exactly 1 file. However the typings on onDrop, onSelect and handleChange are widely typed to accommodate both cases. I'd expect them to be narrowed to accept File as their first argument when multiple is set to falsy value.
Hey! 👋🏼 Thanks a lot for implementing such a time-saver library!
When
multiple
prop is set to a falsy value, it is guaranteed to have exactly 1 file. However the typings ononDrop
,onSelect
andhandleChange
are widely typed to accommodate both cases. I'd expect them to be narrowed to acceptFile
as their first argument whenmultiple
is set to falsy value.Current types:
Expected narrowed types:
This could be achieved by having Props implemented as a generic type. Theoretically with something like:
Tests: