Skip to content

Commit

Permalink
fix(upload): on-error & on-finish props don't allow () => void
Browse files Browse the repository at this point in the history
…type, closes #3290
  • Loading branch information
07akioni committed Jul 17, 2022
1 parent eda7c56 commit 13b13f1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Fix `n-date-picker` will cancel selecting in range mode if click at disabled confirm button, closes [#3254](https://github.com/TuSimple/naive-ui/issues/3254).
- Fix `n-button`'s `focusable` prop doesn't work, closes [#3292](https://github.com/TuSimple/naive-ui/issues/3292).
- Fix `n-upload`'s `on-error` & `on-finish` props don't allow `() => void` type, closes [#3290](https://github.com/TuSimple/naive-ui/issues/3290).

### Feats

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- 修复 `n-date-picker` 在范围模式下点击禁用的确认按钮会取消选择中的状态,关闭 [#3254](https://github.com/TuSimple/naive-ui/issues/3254)
- 修复 `n-button``focusable` 属性不生效,关闭 [#3292](https://github.com/TuSimple/naive-ui/issues/3292)
- 修复 `n-upload``on-error``on-finish` 属性不允许 `() => void` 类型,关闭 [#3290](https://github.com/TuSimple/naive-ui/issues/3290)

### Feats

Expand Down
9 changes: 7 additions & 2 deletions src/upload/src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,21 @@ export type OnChange = (data: {
fileList: SettledFileInfo[]
event: ProgressEvent | Event | undefined
}) => void

export type OnFinish = ({
file,
event
}: {
file: SettledFileInfo
event?: ProgressEvent
}) => FileInfo | undefined
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
}) => FileInfo | undefined | void

export type OnRemove = (data: {
file: SettledFileInfo
fileList: SettledFileInfo[]
}) => Promise<boolean> | boolean | any

export type OnDownload = (
file: SettledFileInfo
) => Promise<boolean> | boolean | any
Expand Down Expand Up @@ -144,7 +148,8 @@ export type OnError = ({
}: {
file: SettledFileInfo
event?: ProgressEvent
}) => FileInfo | undefined
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
}) => FileInfo | undefined | void

export interface FileAndEntry {
file: File
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,3 +462,10 @@ describe('match-type', () => {
).toEqual(true)
})
})

describe('test type', () => {
it('works', () => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const _ = <NUpload onError={() => {}} onFinish={() => {}} />
})
})

0 comments on commit 13b13f1

Please sign in to comment.