diff --git a/mw/Api.d.ts b/mw/Api.d.ts index 9779097..b498503 100644 --- a/mw/Api.d.ts +++ b/mw/Api.d.ts @@ -80,7 +80,7 @@ interface RollbackInfo { title: string; } -interface FinishUpload { +export interface FinishUpload { /** * Call this function to finish the upload. * @@ -231,7 +231,7 @@ declare global { * @param {ApiUploadParams} data Other upload options, see `action=upload` API docs for more * @param {number} [chunkSize] Size (in bytes) per chunk (default: 5MB) * @param {number} [chunkRetries] Amount of times to retry a failed chunk (default: 1) - * @returns {Api.Promise.Upload} + * @returns {Upload.Promise} * @see https://doc.wikimedia.org/mediawiki-core/master/js/mw.Api.html#chunkedUpload */ chunkedUpload( @@ -239,7 +239,7 @@ declare global { data: ApiUploadParams, chunkSize?: number, chunkRetries?: number - ): Api.Promise.Upload; + ): Upload.Promise; /** * Upload a file to the stash, in chunks. @@ -251,7 +251,7 @@ declare global { * @param {ApiUploadParams} [data] * @param {number} [chunkSize] Size (in bytes) per chunk (default: 5MB) * @param {number} [chunkRetries] Amount of times to retry a failed chunk (default: 1) - * @returns {Api.Promise.Upload<[FinishUpload]>} Promise that resolves with a + * @returns {Upload.Promise<[FinishUpload]>} Promise that resolves with a * function that should be called to finish the upload. * @see https://doc.wikimedia.org/mediawiki-core/master/js/mw.Api.html#chunkedUploadToStash */ @@ -260,7 +260,7 @@ declare global { data?: ApiUploadParams, chunkSize?: number, chunkRetries?: number - ): Api.Promise.Upload<[FinishUpload]>; + ): Upload.Promise<[FinishUpload]>; /** * Create a new page. @@ -683,10 +683,10 @@ declare global { * * @param {File|Blob|HTMLInputElement} file HTML `input type=file` element with a file already inside of it, or a File object. * @param {ApiUploadParams} data Other upload options, see `action=upload` API docs for more - * @returns {Api.Promise.Upload} + * @returns {Upload.Promise} * @see https://doc.wikimedia.org/mediawiki-core/master/js/mw.Api.html#upload */ - upload(file: File | Blob | HTMLInputElement, data: ApiUploadParams): Api.Promise.Upload; + upload(file: File | Blob | HTMLInputElement, data: ApiUploadParams): Upload.Promise; /** * Finish an upload in the stash. @@ -721,14 +721,14 @@ declare global { * ``` * @param {File|HTMLInputElement} file * @param {ApiUploadParams} [data] - * @returns {Api.Promise.Upload<[FinishUpload]>} Promise that resolves with a + * @returns {Upload.Promise<[FinishUpload]>} Promise that resolves with a * function that should be called to finish the upload. * @see https://doc.wikimedia.org/mediawiki-core/master/js/mw.Api.html#uploadToStash */ uploadToStash( file: File | HTMLInputElement, data?: ApiUploadParams - ): Api.Promise.Upload<[FinishUpload]>; + ): Upload.Promise<[FinishUpload]>; /** * Convenience method for `action=watch`. diff --git a/mw/Upload.d.ts b/mw/Upload.d.ts index c3615a0..a7bb130 100644 --- a/mw/Upload.d.ts +++ b/mw/Upload.d.ts @@ -1,4 +1,4 @@ -import { ApiResponse } from "./Api"; +import { ApiResponse, FinishUpload } from "./Api"; declare global { namespace mw { @@ -62,10 +62,13 @@ declare global { /** * Finish a stash upload. * - * @returns {JQuery.Promise} + * @returns {Api.Promise<[ApiResponse], Api.RejectArgTuple | [string, ApiResponse]>} * @see https://doc.wikimedia.org/mediawiki-core/master/js/mw.Upload.html#finishStashUpload */ - finishStashUpload(): JQuery.Promise; + finishStashUpload(): Api.Promise< + [ApiResponse], + Api.RejectArgTuple | [string, ApiResponse] + >; /** * Get the mw.Api instance used by this Upload object. @@ -217,18 +220,18 @@ declare global { /** * Upload the file directly. * - * @returns {JQuery.Promise} + * @returns {Upload.Promise} * @see https://doc.wikimedia.org/mediawiki-core/master/js/mw.Upload.html#upload */ - upload(): JQuery.Promise; + upload(): Upload.Promise; /** * Upload the file to the stash to be completed later. * - * @returns {JQuery.Promise} + * @returns {Upload.Promise<[FinishUpload]>} * @see https://doc.wikimedia.org/mediawiki-core/master/js/mw.Upload.html#uploadToStash */ - uploadToStash(): JQuery.Promise; + uploadToStash(): Upload.Promise<[FinishUpload]>; } namespace Upload {