Browse Source

fix: Upload interface generic type (#35158)

* fix:Uplooad组件UploadChangeParam fileList不使用范型

* feat:upload component interface generic test
pull/35186/head
rendaoer 3 years ago
committed by GitHub
parent
commit
ad9e2d9a0e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      components/upload/__tests__/type.test.tsx
  2. 2
      components/upload/interface.tsx

14
components/upload/__tests__/type.test.tsx

@ -35,6 +35,20 @@ describe('Upload.typescript', () => {
expect(upload).toBeTruthy();
});
it('onChange fileList', () => {
type IFile = {
customFile: File;
};
const upload = (
<Upload<IFile> onChange={({ fileList }) => fileList.map(file => file.response?.customFile)}>
<span>click to upload</span>
</Upload>
);
expect(upload).toBeTruthy();
});
it('onChange in UploadProps', () => {
const uploadProps: UploadProps<File> = {
onChange: ({ file }) => file,

2
components/upload/interface.tsx

@ -44,7 +44,7 @@ export interface InternalUploadFile<T = any> extends UploadFile<T> {
export interface UploadChangeParam<T = UploadFile> {
// https://github.com/ant-design/ant-design/issues/14420
file: T;
fileList: UploadFile[];
fileList: T[];
event?: { percent: number };
}

Loading…
Cancel
Save