Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/interface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface UploadProps
accept?: string | AcceptConfig;
multiple?: boolean;
onBatchStart?: (
fileList: { file: RcFile; parsedFile: Exclude<BeforeUploadFileType, boolean> }[],
fileList: { file: RcFile; parsedFile: RcFile }[],
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

In AjaxUploader.tsx, if beforeUpload returns false, processFile returns a ParsedFileInfo object where parsedFile is null (line 212). Since onBatchStart is called with the unfiltered fileList (line 185), parsedFile can indeed be null at runtime. Typing parsedFile strictly as RcFile without allowing null can lead to runtime errors or TypeScript compilation failures in consuming applications that use strictNullChecks. We should update the type to RcFile | null to accurately reflect this possibility.

Suggested change
fileList: { file: RcFile; parsedFile: RcFile }[],
fileList: { file: RcFile; parsedFile: RcFile | null }[],

) => void;
onStart?: (file: RcFile) => void;
onError?: (error: Error, ret: Record<string, unknown>, file: RcFile) => void;
Expand Down Expand Up @@ -60,7 +60,7 @@ export type UploadRequestMethod = 'POST' | 'PUT' | 'PATCH' | 'post' | 'put' | 'p

export type UploadRequestHeader = Record<string, string>;

export type UploadRequestFile = Exclude<BeforeUploadFileType, File | boolean> | RcFile;
export type UploadRequestFile = RcFile;

export interface UploadRequestError extends Error {
status?: number;
Expand Down