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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
15 additions and
1 deletions
-
components/upload/__tests__/type.test.tsx
-
components/upload/interface.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, |
|
|
|
|
|
@ -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 }; |
|
|
|
} |
|
|
|
|
|
|
|