react-component / react-component/upload

Typescript: make arguments optional

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

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
804
Forks
323
Avg merge
12m
Merged PRs (30d)
1

Description

In interface.d.ts in these methods all the arguments are required:

onStart?: (file: RcFile) => void;
onError?: (error: Error, ret: object, file: RcFile) => void;
onSuccess?: (response: object, file: RcFile, xhr: object) => void;
onProgress?: (event: UploadProgressEvent, file: RcFile) => void;
beforeUpload?: (file: RcFile, FileList: RcFile[]) => BeforeUploadFileType | Promise<void | BeforeUploadFileType>;

But in my code I might be not interested in file argument, for example. While all args are required I must still define them and get TS errors for defined and not used variables.

Could you please make these args optional like this:

onSuccess?: (response?: object, file?: RcFile, xhr?: object) => void;

Contributor guide

No contributing guide indexed for this repository

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

Open interface.d.ts and inspect the onStart, onError, onSuccess, onProgress, and beforeUpload callback declarations. Check the existing TypeScript definitions and usage expectations, then verify that callbacks may omit unused parameters without type errors and that the declarations remain valid.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.