|
@@ -99,16 +99,23 @@ declare module Uppy {
|
|
|
totalProgress: number;
|
|
|
}
|
|
|
type LogLevel = 'info' | 'warning' | 'error';
|
|
|
+
|
|
|
+ // This hack accepts _any_ string for `Event`, but also tricks VSCode and friends into providing autocompletions
|
|
|
+ // for the names listed. https://github.com/microsoft/TypeScript/issues/29729#issuecomment-505826972
|
|
|
+ type LiteralUnion<T extends U, U = string> = T | (U & { });
|
|
|
+ type Event = LiteralUnion<'file-added' | 'file-removed' | 'upload' | 'upload-progress' | 'upload-success' | 'complete' | 'error' | 'upload-error' |
|
|
|
+ 'upload-retry' | 'info-visible' | 'info-hidden' | 'cancel-all' | 'restriction-failed' | 'reset-progress'>;
|
|
|
+
|
|
|
class Uppy {
|
|
|
constructor(opts?: Partial<UppyOptions>);
|
|
|
on<TMeta extends IndexedObject<any> = {}>(event: 'upload-success', callback: (file: UppyFile<TMeta>, body: any, uploadURL: string) => void): Uppy;
|
|
|
on<TMeta extends IndexedObject<any> = {}>(event: 'complete', callback: (result: UploadResult<TMeta>) => void): Uppy;
|
|
|
- on(event: string, callback: (...args: any[]) => void): Uppy;
|
|
|
- off(event: string, callback: any): Uppy;
|
|
|
+ on(event: Event, callback: (...args: any[]) => void): Uppy;
|
|
|
+ off(event: Event, callback: any): Uppy;
|
|
|
/**
|
|
|
* For use by plugins only!
|
|
|
*/
|
|
|
- emit(event: string, ...args: any[]): void;
|
|
|
+ emit(event: Event, ...args: any[]): void;
|
|
|
updateAll(state: object): void;
|
|
|
setState(patch: object): void;
|
|
|
getState<TMeta extends IndexedObject<any> = {}>(): State<TMeta>;
|