Typescript: make arguments optional

オープン
#353 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
45/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
typescript
領域
api

調査の方向性

interface.d.tsを開き、onStart、onError、onSuccess、onProgress、beforeUploadのコールバック宣言を確認します。既存のTypeScript定義と想定される使用方法を確認したうえで、コールバックが未使用のパラメーターを省略しても型エラーにならないこと、および宣言が引き続き有効であることを検証します。

索引モデルが issue の本文から書いたものです。

説明

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;
主要言語
TypeScript
スター
804
フォーク
323
平均マージ
12分
マージ済み PR(30日)
1

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

react-component/upload のほかの issue

react-component/upload の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。