Specialize interface file types.#707
Conversation
Files are always parsed into RcFile before being passed to these functions
|
@viliml is attempting to deploy a commit to the React Component Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
概览在 变更上传回调类型精化
估计审查工作量🎯 1 (简单) | ⏱️ ~5 分钟 可能相关的 PR
建议的审查者
诗
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
src/interface.tsxESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request simplifies the TypeScript definitions in src/interface.tsx by replacing complex excluded types with RcFile for onBatchStart's parsedFile and UploadRequestFile. The reviewer identified a potential runtime issue where parsedFile can be null if beforeUpload returns false, and suggested updating the type to RcFile | null to avoid TypeScript compilation failures or runtime errors.
| multiple?: boolean; | ||
| onBatchStart?: ( | ||
| fileList: { file: RcFile; parsedFile: Exclude<BeforeUploadFileType, boolean> }[], | ||
| fileList: { file: RcFile; parsedFile: RcFile }[], |
There was a problem hiding this comment.
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.
| fileList: { file: RcFile; parsedFile: RcFile }[], | |
| fileList: { file: RcFile; parsedFile: RcFile | null }[], |
Files are always parsed into RcFile before being passed to these functions
Summary by CodeRabbit