Forráskód Böngészése

Merge pull request #923 from transloadit/more-typings

Typing improvements
Renée Kooi 6 éve
szülő
commit
4f69ad4a20
30 módosított fájl, 322 hozzáadás és 49 törlés
  1. 1 1
      package.json
  2. 34 0
      packages/@uppy/aws-s3-multipart/types/aws-s3-multipart-tests.ts
  3. 12 6
      packages/@uppy/aws-s3-multipart/types/index.d.ts
  4. 11 0
      packages/@uppy/aws-s3/types/aws-s3-tests.ts
  5. 8 2
      packages/@uppy/aws-s3/types/index.d.ts
  6. 13 0
      packages/@uppy/core/types/core-tests.ts
  7. 16 12
      packages/@uppy/core/types/index.d.ts
  8. 28 0
      packages/@uppy/dashboard/types/dashboard-tests.ts
  9. 8 2
      packages/@uppy/dashboard/types/index.d.ts
  10. 6 0
      packages/@uppy/drag-drop/types/index.d.ts
  11. 6 0
      packages/@uppy/dropbox/types/index.d.ts
  12. 6 0
      packages/@uppy/file-input/types/index.d.ts
  13. 6 0
      packages/@uppy/form/types/index.d.ts
  14. 6 0
      packages/@uppy/golden-retriever/types/index.d.ts
  15. 6 0
      packages/@uppy/google-drive/types/index.d.ts
  16. 6 0
      packages/@uppy/informer/types/index.d.ts
  17. 6 0
      packages/@uppy/instagram/types/index.d.ts
  18. 6 0
      packages/@uppy/progress-bar/types/index.d.ts
  19. 6 0
      packages/@uppy/redux-dev-tools/types/index.d.ts
  20. 3 3
      packages/@uppy/server-utils/types/index.d.ts
  21. 6 0
      packages/@uppy/status-bar/types/index.d.ts
  22. 6 0
      packages/@uppy/thumbnail-generator/types/index.d.ts
  23. 20 6
      packages/@uppy/transloadit/types/index.d.ts
  24. 53 0
      packages/@uppy/transloadit/types/transloadit-tests.ts
  25. 6 0
      packages/@uppy/tus/types/index.d.ts
  26. 6 0
      packages/@uppy/url/types/index.d.ts
  27. 11 9
      packages/@uppy/utils/types/index.d.ts
  28. 9 1
      packages/@uppy/webcam/types/index.d.ts
  29. 6 0
      packages/@uppy/xhr-upload/types/index.d.ts
  30. 5 7
      tsconfig.json

+ 1 - 1
package.json

@@ -95,7 +95,7 @@
     "test:acceptance": "npm run test:prepare-ci && wdio test/endtoend/wdio.remote.conf.js",
     "test:acceptance": "npm run test:prepare-ci && wdio test/endtoend/wdio.remote.conf.js",
     "test:acceptance:local": "npm run test:build && wdio test/endtoend/wdio.local.conf.js",
     "test:acceptance:local": "npm run test:build && wdio test/endtoend/wdio.local.conf.js",
     "test:unit": "jest --testPathPattern=./src --coverage",
     "test:unit": "jest --testPathPattern=./src --coverage",
-    "test:type": "tsc -p packages/uppy/types",
+    "test:type": "tsc -p .",
     "test": "npm run lint && npm run test:unit && npm run test:type",
     "test": "npm run lint && npm run test:unit && npm run test:type",
     "test:watch": "jest --watch --testPathPattern=src",
     "test:watch": "jest --watch --testPathPattern=src",
     "travis:deletecache": "travis cache --delete",
     "travis:deletecache": "travis cache --delete",

+ 34 - 0
packages/@uppy/aws-s3-multipart/types/aws-s3-multipart-tests.ts

@@ -0,0 +1,34 @@
+import Uppy, { UppyFile } from '@uppy/core';
+import AwsS3Multipart, { AwsS3Part } from '../';
+
+{
+  const uppy = Uppy();
+  uppy.use(AwsS3Multipart, {
+    createMultipartUpload(file) {
+      file // $ExpectType UppyFile
+    },
+    listParts(file, opts) {
+      file // $ExpectType UppyFile
+      opts.uploadId // $ExpectType string
+      opts.key // $ExpectType string
+    },
+    prepareUploadPart(file, part) {
+      file // $ExpectType UppyFile
+      part.uploadId // $ExpectType string
+      part.key // $ExpectType string
+      part.body // $ExpectType Blob
+      part.number // $ExpectType number
+    },
+    abortMultipartUpload(file, opts) {
+      file // $ExpectType UppyFile
+      opts.uploadId // $ExpectType string
+      opts.key // $ExpectType string
+    },
+    completeMultipartUpload(file, opts) {
+      file // $ExpectType UppyFile
+      opts.uploadId // $ExpectType string
+      opts.key // $ExpectType string
+      opts.parts[0] // $ExpectType AwsS3Part
+    },
+  });
+}

+ 12 - 6
packages/@uppy/aws-s3-multipart/types/index.d.ts

@@ -1,4 +1,4 @@
-import { Plugin, PluginOptions, Uppy } from '@uppy/core';
+import { Plugin, PluginOptions, Uppy, UppyFile } from '@uppy/core';
 
 
 export interface AwsS3Part {
 export interface AwsS3Part {
   PartNumber: number;
   PartNumber: number;
@@ -8,11 +8,11 @@ export interface AwsS3Part {
 
 
 export interface AwsS3MultipartOptions extends PluginOptions {
 export interface AwsS3MultipartOptions extends PluginOptions {
   serverUrl: string;
   serverUrl: string;
-  createMultipartUpload(file: object): Promise<{uploadId: string, key: string}>;
-  listParts(opts: {uploadId: string, key: string}): Promise<AwsS3Part>;
-  prepareUploadPart(partData: {uploadId: string, key: string, body: Blob, number: number}): Promise<{url: string}>;
-  abortMultipartUpload(opts: {uploadId: string, key: string}): Promise<void>;
-  completeMultipartUpload(opts: {uploadId: string, key: string, parts: AwsS3Part[]}): Promise<{location?: string}>;
+  createMultipartUpload(file: UppyFile): Promise<{uploadId: string, key: string}>;
+  listParts(file: UppyFile, opts: {uploadId: string, key: string}): Promise<AwsS3Part>;
+  prepareUploadPart(file: UppyFile, partData: {uploadId: string, key: string, body: Blob, number: number}): Promise<{url: string}>;
+  abortMultipartUpload(file: UppyFile, opts: {uploadId: string, key: string}): Promise<void>;
+  completeMultipartUpload(file: UppyFile, opts: {uploadId: string, key: string, parts: AwsS3Part[]}): Promise<{location?: string}>;
   timeout: number;
   timeout: number;
   limit: number;
   limit: number;
 }
 }
@@ -20,3 +20,9 @@ export interface AwsS3MultipartOptions extends PluginOptions {
 export default class AwsS3Multipart extends Plugin {
 export default class AwsS3Multipart extends Plugin {
   constructor(uppy: Uppy, opts: Partial<AwsS3MultipartOptions>);
   constructor(uppy: Uppy, opts: Partial<AwsS3MultipartOptions>);
 }
 }
+
+declare module '@uppy/core' {
+  export interface Uppy {
+    use(pluginClass: typeof AwsS3Multipart, opts: Partial<AwsS3MultipartOptions>): Uppy;
+  }
+}

+ 11 - 0
packages/@uppy/aws-s3/types/aws-s3-tests.ts

@@ -0,0 +1,11 @@
+import Uppy, { UppyFile } from '@uppy/core';
+import AwsS3 from '../';
+
+{
+  const uppy = Uppy();
+  uppy.use(AwsS3, {
+    getUploadParameters(file) {
+      file // $ExpectType UppyFile
+    }
+  });
+}

+ 8 - 2
packages/@uppy/aws-s3/types/index.d.ts

@@ -1,4 +1,4 @@
-import { Plugin, PluginOptions, Uppy } from '@uppy/core';
+import { Plugin, PluginOptions, Uppy, UppyFile } from '@uppy/core';
 
 
 export interface AwsS3UploadParameters {
 export interface AwsS3UploadParameters {
   method?: string;
   method?: string;
@@ -9,7 +9,7 @@ export interface AwsS3UploadParameters {
 
 
 export interface AwsS3Options extends PluginOptions {
 export interface AwsS3Options extends PluginOptions {
   serverUrl: string;
   serverUrl: string;
-  getUploadParameters(file: object): Promise<AwsS3UploadParameters>;
+  getUploadParameters(file: UppyFile): Promise<AwsS3UploadParameters>;
   timeout: number;
   timeout: number;
   limit: number;
   limit: number;
 }
 }
@@ -17,3 +17,9 @@ export interface AwsS3Options extends PluginOptions {
 export default class AwsS3 extends Plugin {
 export default class AwsS3 extends Plugin {
   constructor(uppy: Uppy, opts: Partial<AwsS3Options>);
   constructor(uppy: Uppy, opts: Partial<AwsS3Options>);
 }
 }
+
+declare module '@uppy/core' {
+  export interface Uppy {
+    use(pluginClass: typeof AwsS3, opts: Partial<AwsS3Options>): Uppy;
+  }
+}

+ 13 - 0
packages/@uppy/core/types/core-tests.ts

@@ -0,0 +1,13 @@
+import Uppy, { UppyFile } from '../';
+
+{
+  const uppy = Uppy();
+  uppy.addFile({
+    data: new Blob([new ArrayBuffer(1024)], { type: 'application/octet-stream' })
+  });
+
+  uppy.upload().then((result) => {
+    result.successful[0]; // $ExpectType UppyFile
+    result.failed[0]; // $ExpectType UppyFile
+  });
+}

+ 16 - 12
packages/@uppy/core/types/index.d.ts

@@ -1,4 +1,3 @@
-// TODO actually use the properties here
 export interface UppyFile {
 export interface UppyFile {
   data: Blob | File;
   data: Blob | File;
   extension: string;
   extension: string;
@@ -29,6 +28,11 @@ export interface UppyFile {
   uploadURL?: string;
   uploadURL?: string;
 }
 }
 
 
+export interface AddFileOptions extends Partial<UppyFile> {
+  // `.data` is the only required property here.
+  data: Blob | File;
+}
+
 export interface PluginOptions {
 export interface PluginOptions {
   id?: string;
   id?: string;
 }
 }
@@ -71,16 +75,16 @@ export interface UppyOptions {
 }
 }
 
 
 export interface UploadResult {
 export interface UploadResult {
-  successful: Array<UppyFile>;
-  failed: Array<UppyFile>;
+  successful: UppyFile[];
+  failed: UppyFile[];
 }
 }
 
 
 type LogLevel = 'info' | 'warning' | 'error';
 type LogLevel = 'info' | 'warning' | 'error';
 export class Uppy {
 export class Uppy {
   constructor(opts?: Partial<UppyOptions>);
   constructor(opts?: Partial<UppyOptions>);
-  on(event: 'upload-success', callback: (file: UppyFile, body: any, uploadURL: string) => any): Uppy;
+  on(event: 'upload-success', callback: (file: UppyFile, body: any, uploadURL: string) => void): Uppy;
   on(event: 'complete', callback: (result: UploadResult) => void): Uppy;
   on(event: 'complete', callback: (result: UploadResult) => void): Uppy;
-  on(event: string, callback: (...args: any[]) => any): Uppy;
+  on(event: string, callback: (...args: any[]) => void): Uppy;
   off(event: string, callback: any): Uppy;
   off(event: string, callback: any): Uppy;
   updateAll(state: object): void;
   updateAll(state: object): void;
   setState(patch: object): void;
   setState(patch: object): void;
@@ -95,10 +99,10 @@ export class Uppy {
   addUploader(fn: any): void;
   addUploader(fn: any): void;
   removeUploader(fn: any): void;
   removeUploader(fn: any): void;
   setMeta(data: any): void;
   setMeta(data: any): void;
-  setFileMeta(fileID: string, data: any): void;
+  setFileMeta(fileID: string, data: object): void;
   getFile(fileID: string): UppyFile;
   getFile(fileID: string): UppyFile;
   getFiles(): UppyFile[];
   getFiles(): UppyFile[];
-  addFile(file: object): void;
+  addFile(file: AddFileOptions): void;
   removeFile(fileID: string): void;
   removeFile(fileID: string): void;
   pauseResume(fileID: string): boolean;
   pauseResume(fileID: string): boolean;
   pauseAll(): void;
   pauseAll(): void;
@@ -108,18 +112,18 @@ export class Uppy {
   retryUpload(fileID: string): any;
   retryUpload(fileID: string): any;
   reset(): void;
   reset(): void;
   getID(): string;
   getID(): string;
-  use(plugin: typeof Plugin, opts: any): Uppy;
+  use<T extends typeof Plugin>(pluginClass: T, opts: object): Uppy;
   getPlugin(name: string): Plugin;
   getPlugin(name: string): Plugin;
-  iteratePlugins(method: any): void;
+  iteratePlugins(callback: (plugin: Plugin) => void): void;
   removePlugin(instance: Plugin): void;
   removePlugin(instance: Plugin): void;
   close(): void;
   close(): void;
   info(message: string | { message: string; details: string; }, type?: LogLevel, duration?: number): void;
   info(message: string | { message: string; details: string; }, type?: LogLevel, duration?: number): void;
   hideInfo(): void;
   hideInfo(): void;
   log(msg: string, type?: LogLevel): void;
   log(msg: string, type?: LogLevel): void;
   run(): Uppy;
   run(): Uppy;
-  restore(uploadID: string): Promise<any>;
-  addResultData(uploadID: string, data: any): void;
-  upload(): Promise<any>;
+  restore(uploadID: string): Promise<UploadResult>;
+  addResultData(uploadID: string, data: object): void;
+  upload(): Promise<UploadResult>;
 }
 }
 
 
 export default function createUppy(opts?: Partial<UppyOptions>): Uppy;
 export default function createUppy(opts?: Partial<UppyOptions>): Uppy;

+ 28 - 0
packages/@uppy/dashboard/types/dashboard-tests.ts

@@ -0,0 +1,28 @@
+import Uppy from '@uppy/core';
+import Dashboard from '../';
+
+{
+  const uppy = Uppy()
+  uppy.use(Dashboard, {
+    target: 'body'
+  })
+
+  const plugin = <Dashboard>uppy.getPlugin('Dashboard')
+  plugin.openModal()
+  plugin.isModalOpen() // $ExpectType boolean
+  plugin.closeModal()
+}
+
+{
+  const uppy = Uppy()
+  uppy.use(Dashboard, {
+    width: '100%',
+    height: 700
+  })
+}
+
+{
+  const uppy = Uppy()
+  // $ExpectError
+  uppy.use(Dashboard, { height: {} })
+}

+ 8 - 2
packages/@uppy/dashboard/types/index.d.ts

@@ -8,8 +8,8 @@ export interface DashboardOptions extends PluginOptions {
   inline: boolean;
   inline: boolean;
   defaultTabIcon: string;
   defaultTabIcon: string;
   hideUploadButton: boolean;
   hideUploadButton: boolean;
-  width: string;
-  height: string;
+  width: string | number;
+  height: string | number;
   note: string;
   note: string;
   showLinkToFileUploadResult: boolean;
   showLinkToFileUploadResult: boolean;
   proudlyDisplayPoweredByUppy: boolean;
   proudlyDisplayPoweredByUppy: boolean;
@@ -33,3 +33,9 @@ export default class Dashboard extends Plugin {
   install(): void;
   install(): void;
   uninstall(): void;
   uninstall(): void;
 }
 }
+
+declare module '@uppy/core' {
+  export interface Uppy {
+    use(pluginClass: typeof Dashboard, opts: Partial<DashboardOptions>): Uppy;
+  }
+}

+ 6 - 0
packages/@uppy/drag-drop/types/index.d.ts

@@ -11,3 +11,9 @@ export interface DragDropOptions extends PluginOptions {
 export default class DragDrop extends Plugin {
 export default class DragDrop extends Plugin {
   constructor(uppy: Uppy, opts: Partial<DragDropOptions>);
   constructor(uppy: Uppy, opts: Partial<DragDropOptions>);
 }
 }
+
+declare module '@uppy/core' {
+  export interface Uppy {
+    use(pluginClass: typeof DragDrop, opts: Partial<DragDropOptions>): Uppy;
+  }
+}

+ 6 - 0
packages/@uppy/dropbox/types/index.d.ts

@@ -7,3 +7,9 @@ export interface DropboxOptions extends PluginOptions {
 export default class Dropbox extends Plugin {
 export default class Dropbox extends Plugin {
   constructor(uppy: Uppy, opts: Partial<DropboxOptions>);
   constructor(uppy: Uppy, opts: Partial<DropboxOptions>);
 }
 }
+
+declare module '@uppy/core' {
+  export interface Uppy {
+    use(pluginClass: typeof Dropbox, opts: Partial<DropboxOptions>): Uppy;
+  }
+}

+ 6 - 0
packages/@uppy/file-input/types/index.d.ts

@@ -8,3 +8,9 @@ export interface FileInputOptions extends PluginOptions {
 export default class FileInput extends Plugin {
 export default class FileInput extends Plugin {
   constructor(uppy: Uppy, opts: Partial<FileInputOptions>);
   constructor(uppy: Uppy, opts: Partial<FileInputOptions>);
 }
 }
+
+declare module '@uppy/core' {
+  export interface Uppy {
+    use(pluginClass: typeof FileInput, opts: Partial<FileInputOptions>): Uppy;
+  }
+}

+ 6 - 0
packages/@uppy/form/types/index.d.ts

@@ -11,3 +11,9 @@ export interface FormOptions extends PluginOptions {
 export default class Form extends Plugin {
 export default class Form extends Plugin {
   constructor(uppy: Uppy, opts: Partial<FormOptions>);
   constructor(uppy: Uppy, opts: Partial<FormOptions>);
 }
 }
+
+declare module '@uppy/core' {
+  export interface Uppy {
+    use(pluginClass: typeof Form, opts: Partial<FormOptions>): Uppy;
+  }
+}

+ 6 - 0
packages/@uppy/golden-retriever/types/index.d.ts

@@ -9,3 +9,9 @@ export interface GoldenRetrieverOptions extends PluginOptions {
 export default class GoldenRetriever extends Plugin {
 export default class GoldenRetriever extends Plugin {
   constructor(uppy: Uppy, opts: Partial<GoldenRetrieverOptions>);
   constructor(uppy: Uppy, opts: Partial<GoldenRetrieverOptions>);
 }
 }
+
+declare module '@uppy/core' {
+  export interface Uppy {
+    use(pluginClass: typeof GoldenRetriever, opts: Partial<GoldenRetrieverOptions>): Uppy;
+  }
+}

+ 6 - 0
packages/@uppy/google-drive/types/index.d.ts

@@ -8,3 +8,9 @@ export interface GoogleDriveOptions extends PluginOptions {
 export default class GoogleDrive extends Plugin {
 export default class GoogleDrive extends Plugin {
   constructor(uppy: Uppy, opts: Partial<GoogleDriveOptions>);
   constructor(uppy: Uppy, opts: Partial<GoogleDriveOptions>);
 }
 }
+
+declare module '@uppy/core' {
+  export interface Uppy {
+    use(pluginClass: typeof GoogleDrive, opts: Partial<GoogleDriveOptions>): Uppy;
+  }
+}

+ 6 - 0
packages/@uppy/informer/types/index.d.ts

@@ -14,3 +14,9 @@ export interface InformerOptions extends PluginOptions {
 export default class Informer extends Plugin {
 export default class Informer extends Plugin {
   constructor(uppy: Uppy, opts: Partial<InformerOptions>);
   constructor(uppy: Uppy, opts: Partial<InformerOptions>);
 }
 }
+
+declare module '@uppy/core' {
+  export interface Uppy {
+    use(pluginClass: typeof Informer, opts: Partial<InformerOptions>): Uppy;
+  }
+}

+ 6 - 0
packages/@uppy/instagram/types/index.d.ts

@@ -8,3 +8,9 @@ export interface InstagramOptions extends PluginOptions {
 export default class Instagram extends Plugin {
 export default class Instagram extends Plugin {
   constructor(uppy: Uppy, opts: Partial<InstagramOptions>);
   constructor(uppy: Uppy, opts: Partial<InstagramOptions>);
 }
 }
+
+declare module '@uppy/core' {
+  export interface Uppy {
+    use(pluginClass: typeof Instagram, opts: Partial<InstagramOptions>): Uppy;
+  }
+}

+ 6 - 0
packages/@uppy/progress-bar/types/index.d.ts

@@ -8,3 +8,9 @@ export interface ProgressBarOptions extends PluginOptions {
 export default class ProgressBar extends Plugin {
 export default class ProgressBar extends Plugin {
   constructor(uppy: Uppy, opts: Partial<ProgressBarOptions>);
   constructor(uppy: Uppy, opts: Partial<ProgressBarOptions>);
 }
 }
+
+declare module '@uppy/core' {
+  export interface Uppy {
+    use(pluginClass: typeof ProgressBar, opts: Partial<ProgressBarOptions>): Uppy;
+  }
+}

+ 6 - 0
packages/@uppy/redux-dev-tools/types/index.d.ts

@@ -6,3 +6,9 @@ export interface ReduxDevToolsOptions extends PluginOptions {
 export default class ReduxDevTools extends Plugin {
 export default class ReduxDevTools extends Plugin {
   constructor(uppy: Uppy, opts: Partial<ReduxDevToolsOptions>);
   constructor(uppy: Uppy, opts: Partial<ReduxDevToolsOptions>);
 }
 }
+
+declare module '@uppy/core' {
+  export interface Uppy {
+    use(pluginClass: typeof ReduxDevTools, opts: Partial<ReduxDevToolsOptions>): Uppy;
+  }
+}

+ 3 - 3
packages/@uppy/server-utils/types/index.d.ts

@@ -35,7 +35,7 @@ export class Socket {
   constructor (opts: SocketOptions);
   constructor (opts: SocketOptions);
   close (): void;
   close (): void;
   send (action: string, payload: any): void;
   send (action: string, payload: any): void;
-  on (action: string, handler: (any) => void);
-  emit (action: string, payload: (any) => void);
-  once (action: string, handler: (any) => void);
+  on (action: string, handler: (param: any) => void): void;
+  once (action: string, handler: (param: any) => void): void;
+  emit (action: string, payload: (param: any) => void): void;
 }
 }

+ 6 - 0
packages/@uppy/status-bar/types/index.d.ts

@@ -9,3 +9,9 @@ export interface StatusBarOptions extends PluginOptions {
 export default class StatusBar extends Plugin {
 export default class StatusBar extends Plugin {
   constructor(uppy: Uppy, opts: Partial<StatusBarOptions>);
   constructor(uppy: Uppy, opts: Partial<StatusBarOptions>);
 }
 }
+
+declare module '@uppy/core' {
+  export interface Uppy {
+    use(pluginClass: typeof StatusBar, opts: Partial<StatusBarOptions>): Uppy;
+  }
+}

+ 6 - 0
packages/@uppy/thumbnail-generator/types/index.d.ts

@@ -7,3 +7,9 @@ export interface ThumbnailGeneratorOptions extends PluginOptions {
 export default class ThumbnailGenerator extends Plugin {
 export default class ThumbnailGenerator extends Plugin {
   constructor(uppy: Uppy, opts: Partial<ThumbnailGeneratorOptions>);
   constructor(uppy: Uppy, opts: Partial<ThumbnailGeneratorOptions>);
 }
 }
+
+declare module '@uppy/core' {
+  export interface Uppy {
+    use(pluginClass: typeof ThumbnailGenerator, opts: Partial<ThumbnailGeneratorOptions>): Uppy;
+  }
+}

+ 20 - 6
packages/@uppy/transloadit/types/index.d.ts

@@ -1,22 +1,36 @@
-import { Plugin, PluginOptions, Uppy } from '@uppy/core';
+import { Plugin, PluginOptions, Uppy, UppyFile } from '@uppy/core';
+
+export interface AssemblyParameters {
+  auth: { key: string };
+  template_id?: string;
+  steps?: { [step: string]: object };
+  notify_url?: string;
+  fields?: { [name: string]: number | string };
+}
 
 
 export interface AssemblyOptions {
 export interface AssemblyOptions {
-  params: object;
-  fields: object;
-  signature: string;
+  params: AssemblyParameters;
+  fields?: { [name: string]: number | string };
+  signature?: string;
 }
 }
 
 
 export interface TransloaditOptions extends PluginOptions {
 export interface TransloaditOptions extends PluginOptions {
-  params: any;
+  params: AssemblyParameters;
   signature: string;
   signature: string;
   service: string;
   service: string;
   waitForEncoding: boolean;
   waitForEncoding: boolean;
   waitForMetadata: boolean;
   waitForMetadata: boolean;
   importFromUploadURLs: boolean;
   importFromUploadURLs: boolean;
   alwaysRunAssembly: boolean;
   alwaysRunAssembly: boolean;
-  getAssemblyOptions: (file: object) => AssemblyOptions | Promise<AssemblyOptions>;
+  getAssemblyOptions: (file: UppyFile) => AssemblyOptions | Promise<AssemblyOptions>;
 }
 }
 
 
 export default class Transloadit extends Plugin {
 export default class Transloadit extends Plugin {
   constructor(uppy: Uppy, opts: Partial<TransloaditOptions>);
   constructor(uppy: Uppy, opts: Partial<TransloaditOptions>);
 }
 }
+
+declare module '@uppy/core' {
+  export interface Uppy {
+    use(pluginClass: typeof Transloadit, opts: Partial<TransloaditOptions>): Uppy;
+  }
+}

+ 53 - 0
packages/@uppy/transloadit/types/transloadit-tests.ts

@@ -0,0 +1,53 @@
+import Uppy, { UppyFile } from '@uppy/core';
+import Transloadit  from '../';
+
+{
+  const uppy = Uppy();
+  uppy.use(Transloadit, {
+    getAssemblyOptions(file) {
+      file // $ExpectType UppyFile
+    },
+    waitForEncoding: false,
+    waitForMetadata: true,
+    importFromUploadURLs: false,
+    params: {
+      auth: { key: 'abc' },
+      steps: {}
+    }
+  });
+}
+
+{
+  const uppy = Uppy();
+  // $ExpectError
+  uppy.use(Transloadit, { waitForEncoding: null });
+  // $ExpectError
+  uppy.use(Transloadit, { waitForMetadata: null });
+}
+
+{
+  const uppy = Uppy();
+  // $ExpectError
+  uppy.use(Transloadit, { params: {} });
+  // $ExpectError
+  uppy.use(Transloadit, { params: { auth: {} } });
+  // $ExpectError
+  uppy.use(Transloadit, {
+    params: {
+      auth: { key: null }
+    }
+  });
+  // $ExpectError
+  uppy.use(Transloadit, {
+    params: {
+      auth: { key: 'abc' },
+      steps: 'test'
+    }
+  });
+  uppy.use(Transloadit, {
+    params: {
+      auth: { key: 'abc' },
+      steps: { name: {} }
+    }
+  });
+}

+ 6 - 0
packages/@uppy/tus/types/index.d.ts

@@ -12,3 +12,9 @@ export interface TusOptions extends PluginOptions {
 export default class Tus extends Plugin {
 export default class Tus extends Plugin {
   constructor(uppy: Uppy, opts: Partial<TusOptions>);
   constructor(uppy: Uppy, opts: Partial<TusOptions>);
 }
 }
+
+declare module '@uppy/core' {
+  export interface Uppy {
+    use(pluginClass: typeof Tus, opts: Partial<TusOptions>): Uppy;
+  }
+}

+ 6 - 0
packages/@uppy/url/types/index.d.ts

@@ -8,3 +8,9 @@ export interface UrlOptions extends PluginOptions {
 export default class Url extends Plugin {
 export default class Url extends Plugin {
   constructor(uppy: Uppy, opts: Partial<UrlOptions>);
   constructor(uppy: Uppy, opts: Partial<UrlOptions>);
 }
 }
+
+declare module '@uppy/core' {
+  export interface Uppy {
+    use(pluginClass: typeof Url, opts: Partial<UrlOptions>): Uppy;
+  }
+}

+ 11 - 9
packages/@uppy/utils/types/index.d.ts

@@ -1,3 +1,5 @@
+import { UppyFile } from '@uppy/core';
+
 declare module '@uppy/utils/lib/Translator' {
 declare module '@uppy/utils/lib/Translator' {
   export interface TranslatorOptions {
   export interface TranslatorOptions {
     locale: {
     locale: {
@@ -32,7 +34,7 @@ declare module '@uppy/utils/lib/emitSocketProgress' {
     bytesTotal: number;
     bytesTotal: number;
   }
   }
 
 
-  export default function emitSocketProgress(uploader: object, progressData: ProgressData, file: object);
+  export default function emitSocketProgress(uploader: object, progressData: ProgressData, file: UppyFile): void;
 }
 }
 
 
 declare module '@uppy/utils/lib/findAllDOMElements' {
 declare module '@uppy/utils/lib/findAllDOMElements' {
@@ -40,11 +42,11 @@ declare module '@uppy/utils/lib/findAllDOMElements' {
 }
 }
 
 
 declare module '@uppy/utils/lib/findDOMElement' {
 declare module '@uppy/utils/lib/findDOMElement' {
-  export default function findDOMElement(element: string | HTMLElement): HTMLElement?;
+  export default function findDOMElement(element: string | HTMLElement): HTMLElement | null;
 }
 }
 
 
 declare module '@uppy/utils/lib/generateFileID' {
 declare module '@uppy/utils/lib/generateFileID' {
-  export default function generateFileID(file: object): string;
+  export default function generateFileID(file: UppyFile): string;
 }
 }
 
 
 declare module '@uppy/utils/lib/getBytesRemaining' {
 declare module '@uppy/utils/lib/getBytesRemaining' {
@@ -60,7 +62,7 @@ declare module '@uppy/utils/lib/getFileNameAndExtension' {
 }
 }
 
 
 declare module '@uppy/utils/lib/getFileType' {
 declare module '@uppy/utils/lib/getFileType' {
-  export default function getFileType(file: object): string?;
+  export default function getFileType(file: UppyFile): string | null;
 }
 }
 
 
 declare module '@uppy/utils/lib/getFileTypeExtension' {
 declare module '@uppy/utils/lib/getFileTypeExtension' {
@@ -98,10 +100,10 @@ declare module '@uppy/utils/lib/isTouchDevice' {
 declare module '@uppy/utils/lib/limitPromises' {
 declare module '@uppy/utils/lib/limitPromises' {
   // TODO guess this could be generic but it's probably fine this way
   // TODO guess this could be generic but it's probably fine this way
   // because it's mostly for internal use
   // because it's mostly for internal use
-  type LimitedFunction = (...args: any[]) => Promise<any>;
-  type LimitedFunctionFactory = (fn: function) => LimitedFunction;
+  type LimitedFunction<T> = (...args: any[]) => Promise<T>;
+  type LimitedFunctionFactory<T> = (fn: (...args: any[]) => Promise<T>) => LimitedFunction<T>;
 
 
-  export default function limitPromises(limit: number): LimitedFunctionFactory;
+  export default function limitPromises<T>(limit: number): LimitedFunctionFactory<T>;
 }
 }
 
 
 declare module '@uppy/utils/lib/prettyETA' {
 declare module '@uppy/utils/lib/prettyETA' {
@@ -113,9 +115,9 @@ declare module '@uppy/utils/lib/secondsToTime' {
 }
 }
 
 
 declare module '@uppy/utils/lib/settle' {
 declare module '@uppy/utils/lib/settle' {
-  export default function settle(promises: Promise[]): Promise<{ successful: any[], failed: any[] }>;
+  export default function settle<T>(promises: Promise<T>[]): Promise<{ successful: T[], failed: any[] }>;
 }
 }
 
 
 declare module '@uppy/utils/lib/toArray' {
 declare module '@uppy/utils/lib/toArray' {
-  export default function toArray(list: any): Array;
+  export default function toArray(list: any): any[];
 }
 }

+ 9 - 1
packages/@uppy/webcam/types/index.d.ts

@@ -1,13 +1,21 @@
 import { Plugin, PluginOptions, Uppy } from '@uppy/core';
 import { Plugin, PluginOptions, Uppy } from '@uppy/core';
 
 
+export type WebcamMode = 'video-audio' | 'video-only' | 'audio-only' | 'picture';
+
 export interface WebcamOptions extends PluginOptions {
 export interface WebcamOptions extends PluginOptions {
   onBeforeSnapshot?: () => Promise<void>;
   onBeforeSnapshot?: () => Promise<void>;
   countdown?: number | boolean;
   countdown?: number | boolean;
   mirror?: boolean;
   mirror?: boolean;
   facingMode?: string;
   facingMode?: string;
-  modes: Array<'video-audio' | 'video-only' | 'audio-only' | 'picturee'>;
+  modes: WebcamMode[];
 }
 }
 
 
 export default class Webcam extends Plugin {
 export default class Webcam extends Plugin {
   constructor(uppy: Uppy, opts: Partial<WebcamOptions>);
   constructor(uppy: Uppy, opts: Partial<WebcamOptions>);
 }
 }
+
+declare module '@uppy/core' {
+  export interface Uppy {
+    use(pluginClass: typeof Webcam, opts: Partial<WebcamOptions>): Uppy;
+  }
+}

+ 6 - 0
packages/@uppy/xhr-upload/types/index.d.ts

@@ -16,3 +16,9 @@ export interface XHRUploadOptions extends PluginOptions {
 export default class XHRUpload extends Plugin {
 export default class XHRUpload extends Plugin {
   constructor(uppy: Uppy, opts: Partial<XHRUploadOptions>);
   constructor(uppy: Uppy, opts: Partial<XHRUploadOptions>);
 }
 }
+
+declare module '@uppy/core' {
+  export interface Uppy {
+    use(pluginClass: typeof XHRUpload, opts: Partial<XHRUploadOptions>): Uppy;
+  }
+}

+ 5 - 7
packages/uppy/types/tsconfig.json → tsconfig.json

@@ -9,10 +9,6 @@
     "noImplicitAny": true,
     "noImplicitAny": true,
     "noImplicitThis": true,
     "noImplicitThis": true,
     "strictNullChecks": true,
     "strictNullChecks": true,
-    "baseUrl": "../",
-    "typeRoots": [
-      "../"
-    ],
     "types": [],
     "types": [],
     "noEmit": true,
     "noEmit": true,
     "esModuleInterop": true,
     "esModuleInterop": true,
@@ -20,8 +16,10 @@
     "strictFunctionTypes": true,
     "strictFunctionTypes": true,
     "forceConsistentCasingInFileNames": true
     "forceConsistentCasingInFileNames": true
   },
   },
-  "files": [
-    "index.d.ts",
-    "uppy-tests.ts"
+  "include": [
+    "packages/*/types/index.d.ts",
+    "packages/*/types/*-tests.ts",
+    "packages/@uppy/*/types/index.d.ts",
+    "packages/@uppy/*/types/*-tests.ts",
   ]
   ]
 }
 }