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: type more events #4719

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 22 additions & 13 deletions packages/@uppy/core/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ export type ProgressCallback = (progress: number) => void
export type PreProcessCompleteCallback<TMeta extends IndexedObject<any>> = (
file: UppyFile<TMeta> | undefined,
) => void
export type UploadPauseCallback = (
fileID: UppyFile['id'] | undefined,
isPaused: boolean,
) => void
export type UploadProgressCallback<TMeta extends IndexedObject<any>> = (
file: UppyFile<TMeta> | undefined,
progress: FileProgress,
Expand All @@ -253,6 +257,8 @@ export type UploadErrorCallback<TMeta extends IndexedObject<any>> = (
response?: ErrorResponse,
) => void
export type UploadRetryCallback = (fileID: string) => void
export type PauseAllCallback = (fileIDs: string[]) => void
export type ResumeAllCallback = (fileIDs: string[]) => void
export type RetryAllCallback = (fileIDs: string[]) => void
export type RestrictionFailedCallback<TMeta extends IndexedObject<any>> = (
file: UppyFile<TMeta> | undefined,
Expand All @@ -262,24 +268,27 @@ export type RestrictionFailedCallback<TMeta extends IndexedObject<any>> = (
export interface UppyEventMap<
TMeta extends IndexedObject<any> = Record<string, unknown>,
> {
'cancel-all': GenericEventCallback
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generic, because we don't have a special type for it like with others?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few of them are generic, I'm not sure what the reason is, it was done as part of #3085

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's for all events that are not unique and have the same type. It's just for reusability.

complete: UploadCompleteCallback<TMeta>
error: ErrorCallback
'file-added': FileAddedCallback<TMeta>
'files-added': FilesAddedCallback<TMeta>
'file-removed': FileRemovedCallback<TMeta>
upload: UploadCallback
progress: ProgressCallback
'files-added': FilesAddedCallback<TMeta>
'info-hidden': GenericEventCallback
'info-visible': GenericEventCallback
'pause-all': PauseAllCallback
'preprocess-complete': PreProcessCompleteCallback<TMeta>
'upload-progress': UploadProgressCallback<TMeta>
'upload-success': UploadSuccessCallback<TMeta>
complete: UploadCompleteCallback<TMeta>
error: ErrorCallback
progress: ProgressCallback
'reset-progress': GenericEventCallback
'resume-all': ResumeAllCallback
'restriction-failed': RestrictionFailedCallback<TMeta>
'retry-all': RetryAllCallback
'upload-error': UploadErrorCallback<TMeta>
'upload-pause': UploadPauseCallback
'upload-progress': UploadProgressCallback<TMeta>
'upload-retry': UploadRetryCallback
'retry-all': RetryAllCallback
'info-visible': GenericEventCallback
'info-hidden': GenericEventCallback
'cancel-all': GenericEventCallback
'restriction-failed': RestrictionFailedCallback<TMeta>
'reset-progress': GenericEventCallback
'upload-success': UploadSuccessCallback<TMeta>
upload: UploadCallback
}

export class Uppy {
Expand Down