diff --git a/packages/@uppy/core/types/index.d.ts b/packages/@uppy/core/types/index.d.ts index 47db6bf88..99e563036 100644 --- a/packages/@uppy/core/types/index.d.ts +++ b/packages/@uppy/core/types/index.d.ts @@ -2,17 +2,16 @@ interface IndexedObject { [key: string]: T; [key: number]: T; } -export interface UppyFile { +export interface UppyFile = {}> { data: Blob | File; - error?: string; extension: string; id: string; isPaused?: boolean; isRemote: boolean; meta: { - name: string; - type?: string; - } & IndexedObject; + name: string; + type?: string; + } & TMeta; name: string; preview?: string; progress?: { @@ -30,7 +29,14 @@ export interface UppyFile { size: number; source?: string; type?: string; - uploadURL?: string; +} + +export interface UploadedUppyFile = {}> extends UppyFile { + uploadURL: string; +} + +export interface FailedUppyFile = {}> extends UppyFile { + error: string; } export interface AddFileOptions extends Partial { @@ -86,16 +92,16 @@ export interface UppyOptions { store: Store; } -export interface UploadResult { - successful: UppyFile[]; - failed: UppyFile[]; +export interface UploadResult = {}> { + successful: UploadedUppyFile[]; + failed: FailedUppyFile[]; } -interface State extends IndexedObject { +interface State = {}> extends IndexedObject { capabilities?: {resumableUploads?: boolean}; currentUploads: {}; error?: string; - files: {[key: string]: UppyFile}; + files: {[key: string]: UploadedUppyFile | FailedUppyFile}; info?: { isHidden: boolean; type: string; @@ -114,7 +120,7 @@ export class Uppy { off(event: string, callback: any): Uppy; updateAll(state: object): void; setState(patch: object): void; - getState(): State; + getState = {}>(): State; readonly state: State; setFileState(fileID: string, state: object): void; resetProgress(): void; @@ -126,8 +132,8 @@ export class Uppy { removeUploader(fn: any): void; setMeta(data: any): void; setFileMeta(fileID: string, data: object): void; - getFile(fileID: string): UppyFile; - getFiles(): UppyFile[]; + getFile = {}>(fileID: string): UppyFile; + getFiles = {}>(): Array>; addFile(file: AddFileOptions): void; removeFile(fileID: string): void; pauseResume(fileID: string): boolean;