react-dropzone / react-dropzone/attr-accept

More specific type for acceptedFiles param

Open
#100 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
120
Forks
23
Avg merge
1d 10h
Merged PRs (30d)
7

Description

Small suggestion to improve the type of the acceptedFiles param.

In my project I use:

type NonEmptyArray<T = unknown> = [T, ...T[]];
type UniqueFileTypeSpecifier = `${string}/${string}` | `.${string}`;
type AcceptedFiles = UniqueFileTypeSpecifier | NonEmptyArray<UniqueFileTypeSpecifier>

Not perfect but it does at least give some indicator. I don't use the comma-separated feature but my type should also allow that.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at src/index.js line 8, where the acceptedFiles parameter is defined. Review how the parameter currently accepts single and comma-separated file type values, then check the project's existing type-checking or test setup. Done means the parameter type communicates the supported formats, including the comma-separated form.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
frontend
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.