Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@uppy/core,@uppy/dashboard: fix types for some events #3812

Merged
merged 1 commit into from Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/@uppy/core/types/index.d.ts
Expand Up @@ -209,12 +209,12 @@ export type FilesAddedCallback<TMeta> = (files: UppyFile<TMeta>[]) => void;
export type FileRemovedCallback<TMeta> = (file: UppyFile<TMeta>, reason: FileRemoveReason) => void;
export type UploadCallback = (data: { id: string, fileIDs: string[] }) => void;
export type ProgressCallback = (progress: number) => void;
export type PreProcessCompleteCallback<TMeta> = (file: UppyFile<TMeta>) => void;
export type UploadProgressCallback<TMeta> = (file: UppyFile<TMeta>, progress: FileProgress) => void;
export type UploadSuccessCallback<TMeta> = (file: UppyFile<TMeta>, response: SuccessResponse) => void
export type PreProcessCompleteCallback<TMeta> = (file: UppyFile<TMeta> | undefined) => void;
export type UploadProgressCallback<TMeta> = (file: UppyFile<TMeta> | undefined, progress: FileProgress) => void;
export type UploadSuccessCallback<TMeta> = (file: UppyFile<TMeta> | undefined, response: SuccessResponse) => void
export type UploadCompleteCallback<TMeta> = (result: UploadResult<TMeta>) => void
export type ErrorCallback = (error: Error) => void;
export type UploadErrorCallback<TMeta> = (file: UppyFile<TMeta>, error: Error, response?: ErrorResponse) => void;
export type UploadErrorCallback<TMeta> = (file: UppyFile<TMeta> | undefined, error: Error, response?: ErrorResponse) => void;
export type UploadRetryCallback = (fileID: string) => void;
// TODO: reverse the order in the next major version
export type RestrictionFailedCallback<TMeta> = (file: UppyFile<TMeta> | undefined, error: Error) => void;
Expand Down
6 changes: 3 additions & 3 deletions packages/@uppy/core/types/index.test-d.ts
Expand Up @@ -104,8 +104,8 @@ type anyObject = Record<string, unknown>
})

// Separate event handlers
const handleUpload = (file: UppyFile<Meta>) => {
const meta = file.meta.myCustomMetadata
const handleUpload = (file?: UppyFile<Meta>) => {
const meta = file?.meta.myCustomMetadata
}

uppy.off<'upload-success', Meta>('upload-success', handleUpload)
Expand All @@ -114,7 +114,7 @@ type anyObject = Record<string, unknown>
body?: { someValue: string }
}

const onUploadSuccess = async (file: UppyFile<Meta, any>, response: CustomResponse) => {
const onUploadSuccess = async (file: UppyFile<Meta, any> | undefined, response: CustomResponse) => {
const res = response.body?.someValue
}
uppy.on<'upload-success', Meta>('upload-success', onUploadSuccess)
Expand Down
4 changes: 2 additions & 2 deletions packages/@uppy/dashboard/types/index.d.ts
Expand Up @@ -84,8 +84,8 @@ export default Dashboard

// Events

export type DashboardFileEditStartCallback<TMeta> = (file: UppyFile<TMeta>) => void;
export type DashboardFileEditCompleteCallback<TMeta> = (file: UppyFile<TMeta>) => void;
export type DashboardFileEditStartCallback<TMeta> = (file?: UppyFile<TMeta>) => void;
export type DashboardFileEditCompleteCallback<TMeta> = (file?: UppyFile<TMeta>) => void;
declare module '@uppy/core' {
export interface UppyEventMap<TMeta> {
'dashboard:modal-open': GenericEventCallback
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/dashboard/types/index.test-d.ts
Expand Up @@ -54,7 +54,7 @@ import Dashboard from '..'

uppy.on('dashboard:file-edit-state', (file) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const fileName = file.name
const fileName = file?.name
})
}

Expand Down