Skip to content

Commit

Permalink
fix: Upload interface generic type (#35158)
Browse files Browse the repository at this point in the history
* fix:Uplooad组件UploadChangeParam fileList不使用范型

* feat:upload component interface generic test
  • Loading branch information
rendaoer committed Apr 22, 2022
1 parent 26707f1 commit ad9e2d9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions components/upload/__tests__/type.test.tsx
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion components/upload/interface.tsx
Expand Up @@ -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 };
}

Expand Down

0 comments on commit ad9e2d9

Please sign in to comment.