`
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Api-method-getErrorMessage
*/
@@ -324,7 +317,7 @@ declare global {
* ```
*
* @param {TitleLike} title Page title
- * @param {(data: { timestamp: string, content: string }) => string | ApiEditPageParams} transform Callback that prepares the edit
+ * @param {function({ timestamp: string, content: string }):string|ApiEditPageParams} transform Callback that prepares the edit
* @returns {JQuery.Promise
}
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Api.plugin.edit-method-edit
*/
@@ -516,10 +509,10 @@ declare global {
* Get the categories that a particular page on the wiki belongs to.
*
* @param {TitleLike} title
- * @returns {JQuery.Promise} List of category titles or false if title was not found
+ * @returns {JQuery.Promise} List of category titles or false if title was not found
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Api.plugin.category-method-getCategories
*/
- getCategories(title: TitleLike): JQuery.Promise;
+ getCategories(title: TitleLike): JQuery.Promise;
/**
* Convenience method for `action=rollback`.
@@ -558,7 +551,7 @@ declare global {
*
* This function will return a promise that will resolve with a function to finish the stash upload.
*
- * @param {File | HTMLInputElement} file
+ * @param {File|HTMLInputElement} file
* @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)
@@ -577,9 +570,9 @@ declare global {
*
* The file will be uploaded using AJAX and FormData.
*
- * @param {HTMLInputElement | File | Blob} file HTML `input type=file` element with a file already inside of it, or a File object.
+ * @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
- * @return {JQuery.Promise}
+ * @returns {JQuery.Promise}
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Api.plugin.upload-method-upload
*/
upload(
@@ -613,9 +606,8 @@ declare global {
* } );
* ```
*
- * @param {File | HTMLInputElement} file
+ * @param {File|HTMLInputElement} file
* @param {ApiUploadParams} [data]
- * @return {JQuery.Promise}
* @returns {JQuery.Promise<(data?: ApiUploadParams) => JQuery.Promise>} Call this function to finish the upload
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Api.plugin.upload-method-uploadToStash
*/
diff --git a/mw/ForeignApi.d.ts b/mw/ForeignApi.d.ts
index 321c5d6..4577a2c 100644
--- a/mw/ForeignApi.d.ts
+++ b/mw/ForeignApi.d.ts
@@ -49,7 +49,7 @@ declare global {
* Return the origin to use for API requests, in the required format (protocol, host and port, if any).
*
* @protected
- * @return {string | undefined}
+ * @returns {string|undefined}
*/
protected getOrigin(): string | undefined;
}
diff --git a/mw/ForeignRest.d.ts b/mw/ForeignRest.d.ts
index d1624af..7638b36 100644
--- a/mw/ForeignRest.d.ts
+++ b/mw/ForeignRest.d.ts
@@ -44,7 +44,7 @@ declare global {
* @param {string | Uri} url URL pointing to another wiki's rest.php endpoint.
* @param {ForeignApi} foreignActionApi
* @param {ForeignRestOptions} [options]
- * @since 1.26
+ * @since 1.36
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.ForeignApi-method-constructor
*/
constructor(
diff --git a/mw/Map.d.ts b/mw/Map.d.ts
index 0944f4d..dbf9e8d 100644
--- a/mw/Map.d.ts
+++ b/mw/Map.d.ts
@@ -12,6 +12,15 @@ declare global {
class Map = any> {
private values: V;
+ /**
+ * Check if a given key exists in the map.
+ *
+ * @param selection Key to check
+ * @returns True if the key exists
+ * @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Map-method-exists
+ */
+ exists(selection: keyof V): boolean;
+
/**
* Get the value of one or more keys.
*
@@ -23,9 +32,9 @@ declare global {
* an object of key/values. If no selection is passed, a new object with all key/values is returned.
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Map-method-get
*/
- get(): V;
get(selection: S[], fallback?: any): Pick;
get(selection: S, fallback?: V[S]): V[S];
+ get(): V;
/**
* Set the value of one or more keys.
@@ -37,15 +46,6 @@ declare global {
*/
set(selection: S, value: V[S]): boolean;
set(selection: Partial): boolean;
-
- /**
- * Check if a given key exists in the map.
- *
- * @param selection Key to check
- * @returns True if the key exists
- * @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Map-method-exists
- */
- exists(selection: keyof V): boolean;
}
}
}
diff --git a/mw/RegExp.d.ts b/mw/RegExp.d.ts
index 5518e1a..6966c7d 100644
--- a/mw/RegExp.d.ts
+++ b/mw/RegExp.d.ts
@@ -14,7 +14,7 @@ declare global {
* @deprecated
* @since 1.26; deprecated since 1.34
* @param {string} str String to escape
- * @return {string} Escaped string
+ * @returns {string} Escaped string
* @see https://doc.wikimedia.org/mediawiki-core/REL1_29/js/source/mediawiki.RegExp.html#mw-RegExp-static-method-escape
*/
function escape(str: string): string;
diff --git a/mw/Rest.d.ts b/mw/Rest.d.ts
index 3026533..df5919f 100644
--- a/mw/Rest.d.ts
+++ b/mw/Rest.d.ts
@@ -40,15 +40,11 @@ declare global {
*/
constructor(options?: Partial);
- /**
- * @private
- */
- defaults: RestOptions;
+ private defaults: RestOptions;
/**
* Abort all unfinished requests issued by this Api object.
*
- * @returns {void}
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Rest-method-abort
*/
abort(): void;
diff --git a/mw/Title.d.ts b/mw/Title.d.ts
index 172c91e..2b55b07 100644
--- a/mw/Title.d.ts
+++ b/mw/Title.d.ts
@@ -1,6 +1,6 @@
import { QueryParams } from "./Uri";
-type title = string | mw.Title;
+export type TitleLike = string | mw.Title;
declare global {
namespace mw {
@@ -33,7 +33,6 @@ declare global {
/**
* Store page existence
*
- * @property {Object} exist
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Title-static-property-exist
*/
static exist: {
@@ -57,15 +56,14 @@ declare global {
* Title.exist.set( ['File:Foo_bar.jpg', ...], false );
* ```
*
- * @param {string|Array} titles Title(s) in strict prefixedDb title form
+ * @param {string|string[]} titles Title(s) in strict prefixedDb title form
* @param {boolean} [state=true] State of the given titles
- * @return {boolean}
+ * @returns {boolean}
*/
set(titles: string | string[], state?: boolean): boolean;
};
/**
- * @method constructor
* @param {string} title Title of the page. If no second argument given,
* this will be searched for a namespace
* @param {number} [namespace=NS_MAIN] If given, will used as default namespace for the given title
@@ -77,7 +75,7 @@ declare global {
/**
* Check the title can have an associated talk page
*
- * @return {boolean} The title can have an associated talk page
+ * @returns {boolean} The title can have an associated talk page
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Title-method-canHaveTalkPage
*/
canHaveTalkPage(): boolean;
@@ -85,7 +83,7 @@ declare global {
/**
* Whether this title exists on the wiki.
*
- * @return {boolean|null} Boolean if the information is available, otherwise null
+ * @returns {boolean|null} Boolean if the information is available, otherwise null
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Title-method-exists
*/
exists(): boolean | null;
@@ -93,7 +91,7 @@ declare global {
/**
* Get the extension of the page name (if any)
*
- * @return {string|null} Name extension or null if there is none
+ * @returns {string|null} Name extension or null if there is none
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Title-method-getExtension
*/
getExtension(): string | null;
@@ -106,7 +104,7 @@ declare global {
* Note that this method will work for non-file titles but probably give nonsensical results.
* A title like "User:Dr._J._Fail" will be returned as "Dr. J"! Use {@link getMainText} instead.
*
- * @return {string}
+ * @returns {string}
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Title-method-getFileNameTextWithoutExtension
*/
getFileNameTextWithoutExtension(): string;
@@ -119,7 +117,7 @@ declare global {
* Note that this method will work for non-file titles but probably give nonsensical results.
* A title like "User:Dr._J._Fail" will be returned as "Dr._J"! Use {@link getMain} instead.
*
- * @return {string}
+ * @returns {string}
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Title-method-getFileNameWithoutExtension
*/
getFileNameWithoutExtension(): string;
@@ -130,7 +128,7 @@ declare global {
* Note that this method (by design) does not include the hash character and
* the value is not url encoded.
*
- * @return {string|null}
+ * @returns {string|null}
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Title-method-getFragment
*/
getFragment(): string | null;
@@ -140,7 +138,7 @@ declare global {
*
* Example: "Example_image.svg" for "File:Example_image.svg".
*
- * @return {string}
+ * @returns {string}
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Title-method-getMain
*/
getMain(): string;
@@ -150,7 +148,7 @@ declare global {
*
* Example: "Example image.svg" for "File:Example_image.svg".
*
- * @return {string}
+ * @returns {string}
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Title-method-getMainText
*/
getMainText(): string;
@@ -161,7 +159,7 @@ declare global {
* "Dr. J"! Use {@link getMain} or {@link getMainText} for the actual page name.
*
* @deprecated since 1.40, use {@link getFileNameWithoutExtension} instead
- * @return {string} File name without file extension, in the canonical form with underscores
+ * @returns {string} File name without file extension, in the canonical form with underscores
* instead of spaces. For example, the title "File:Example_image.svg" will be returned as
* "Example_image".
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Title-method-getName
@@ -173,7 +171,7 @@ declare global {
*
* Example: 6 for "File:Example_image.svg".
*
- * @return {number}
+ * @returns {number}
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Title-method-getNamespaceId
*/
getNamespaceId(): number;
@@ -184,7 +182,7 @@ declare global {
* Example: "File:" for "File:Example_image.svg".
* In #NS_MAIN this is '', otherwise namespace name plus ':'
*
- * @return {string}
+ * @returns {string}
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Title-method-getNamespacePrefix
*/
getNamespacePrefix(): string;
@@ -195,7 +193,7 @@ declare global {
* "Dr. J"! Use {@link getMainText} for the actual page name.
*
* @deprecated since 1.40, use {@link getFileNameTextWithoutExtension} instead
- * @return {string} File name without file extension, formatted with spaces instead of
+ * @returns {string} File name without file extension, formatted with spaces instead of
* underscores. For example, the title "File:Example_image.svg" will be returned as
* "Example image".
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Title-method-getNameText
@@ -208,7 +206,7 @@ declare global {
* Example: "File:Example_image.svg".
* Most useful for API calls, anything that must identify the "title".
*
- * @return {string}
+ * @returns {string}
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Title-method-getPrefixedDb
*/
getPrefixedDb(): string;
@@ -218,7 +216,7 @@ declare global {
*
* Example: "File:Example image.svg" for "File:Example_image.svg".
*
- * @return {string}
+ * @returns {string}
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Title-method-getPrefixedText
*/
getPrefixedText(): string;
@@ -233,7 +231,7 @@ declare global {
* - "Foo:Bar" relative to any namespace other than Foo stays "Foo:Bar".
*
* @param {number} namespace The namespace to be relative to
- * @return {string}
+ * @returns {string}
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Title-method-getRelativeText
*/
getRelativeText(namespace: number): string;
@@ -241,7 +239,7 @@ declare global {
/**
* Get the title for the subject page of a talk page
*
- * @return {Title|null} The title for the subject page of a talk page, null if not available
+ * @returns {Title|null} The title for the subject page of a talk page, null if not available
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Title-method-getSubjectPage
*/
getSubjectPage(): Title | null;
@@ -249,7 +247,7 @@ declare global {
/**
* Get the title for the associated talk page
*
- * @return {Title|null} The title for the associated talk page, null if not available
+ * @returns {Title|null} The title for the associated talk page, null if not available
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Title-method-getTalkPage
*/
getTalkPage(): Title | null;
@@ -257,9 +255,9 @@ declare global {
/**
* Get the URL to this title
*
- * @param {Object} [params] A mapping of query parameter names to values,
+ * @param {QueryParams} [params] A mapping of query parameter names to values,
* e.g. `{ action: 'edit' }`.
- * @return {string}
+ * @returns {string}
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Title-method-getUrl
*/
getUrl(params?: QueryParams): string;
@@ -267,27 +265,21 @@ declare global {
/**
* Check if the title is in a talk namespace
*
- * @return {boolean} The title is in a talk namespace
+ * @returns {boolean} The title is in a talk namespace
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Title-method-isTalkPage
*/
isTalkPage(): boolean;
/**
- * Alias of {@link mw.Title.getPrefixedDb}
+ * Alias of {@link getPrefixedDb}
*
- * TODO: Use @-alias when we switch to JSDoc
- *
- * @method
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Title-method-toString
*/
toString(): string;
/**
- * Alias of {@link mw.Title.getPrefixedText}
- *
- * TODO: Use @-alias when we switch to JSDoc
+ * Alias of {@link getPrefixedText}
*
- * @method
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Title-method-toText
*/
toText(): string;
@@ -296,11 +288,11 @@ declare global {
* Whether this title exists on the wiki.
*
* @param {string|Title} title prefixed db-key name (string) or instance of Title
- * @return {boolean|null} Boolean if the information is available, otherwise null
+ * @returns {boolean|null} Boolean if the information is available, otherwise null
* @throws {Error} If title is not a string or mw.Title
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Title-static-method-exists
*/
- static exists(title: title): boolean | null;
+ static exists(title: TitleLike): boolean | null;
/**
* Check if a given namespace is a talk namespace
@@ -308,7 +300,7 @@ declare global {
* See NamespaceInfo::isTalk in PHP
*
* @param {number} namespaceId Namespace ID
- * @return {boolean} Namespace is a talk namespace
+ * @returns {boolean} Namespace is a talk namespace
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Title-method-isTalkNamespace
*/
static isTalkNamespace(namespaceId: number): boolean;
@@ -324,7 +316,7 @@ declare global {
*
* @param {number} namespace Namespace to use for the title
* @param {string} title
- * @return {Title|null} A valid Title object or null if the title is invalid
+ * @returns {Title|null} A valid Title object or null if the title is invalid
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Title-static-method-makeTitle
*/
static makeTitle(namespace: number, title: string): Title | null;
@@ -336,7 +328,7 @@ declare global {
*
* @param {string} uncleanName The unclean file name including file extension but
* without namespace
- * @return {Title|null} A valid Title object or null if the title is invalid
+ * @returns {Title|null} A valid Title object or null if the title is invalid
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Title-static-method-newFromFileName
*/
static newFromFileName(uncleanName: string): Title | null;
@@ -349,7 +341,7 @@ declare global {
* ```
*
* @param {HTMLElement|JQuery} img The image to use as a base
- * @return {Title|null} The file title or null if unsuccessful
+ * @returns {Title|null} The file title or null if unsuccessful
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Title-static-method-newFromImg
*/
static newFromImg(img: HTMLElement | JQuery): Title;
@@ -363,7 +355,7 @@ declare global {
*
* @param {string} title
* @param {number} [namespace=NS_MAIN] Default namespace
- * @return {Title|null} A valid Title object or null if the title is invalid
+ * @returns {Title|null} A valid Title object or null if the title is invalid
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Title-static-method-newFromText
*/
static newFromText(title: string, namespace?: number): Title | null;
@@ -380,7 +372,7 @@ declare global {
* Makes sure that a file is uploadable under the title returned.
* There are pages in the file namespace under which file upload is impossible.
* Automatically assumed if the title is created in the Media namespace.
- * @return {Title|null} A valid Title object or null if the input cannot be turned into a valid title
+ * @returns {Title|null} A valid Title object or null if the input cannot be turned into a valid title
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Title-static-method-newFromUserInput
*/
static newFromUserInput(
@@ -395,7 +387,7 @@ declare global {
* Keep in sync with File::normalizeExtension() in PHP.
*
* @param {string} extension File extension (without the leading dot)
- * @return {string} File extension in canonical form
+ * @returns {string} File extension in canonical form
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Title-method-normalizeExtension
*/
static normalizeExtension(extension: string): string;
@@ -404,7 +396,7 @@ declare global {
* PHP's strtoupper differs from {@link String.toUpperCase} in a number of cases (T147646).
*
* @param {string} chr Unicode character
- * @return {string} Unicode character, in upper case, according to the same rules as in PHP
+ * @returns {string} Unicode character, in upper case, according to the same rules as in PHP
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Title-method-phpCharToUpper
*/
static phpCharToUpper(chr: string): string;
@@ -415,7 +407,7 @@ declare global {
* See NamespaceInfo::wantSignatures in PHP
*
* @param {number} namespaceId Namespace ID
- * @return {boolean} Namespace is a signature namespace
+ * @returns {boolean} Namespace is a signature namespace
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Title-method-wantSignaturesNamespace
*/
static wantSignatureNamespace(namespaceId: number): boolean;
diff --git a/mw/Uri.d.ts b/mw/Uri.d.ts
index 8372f9f..d2f3a48 100644
--- a/mw/Uri.d.ts
+++ b/mw/Uri.d.ts
@@ -23,11 +23,9 @@ declare global {
* A factory method to create an mw.Uri class with a default location to resolve relative URLs
* against (including protocol-relative URLs).
*
- * @method
* @param {string|Function} documentLocation A full url, or function returning one.
* If passed a function, the return value may change over time and this will be honoured. (T74334)
- * @member mw
- * @return {Function} An mw.Uri class constructor
+ * @returns {Function} An mw.Uri class constructor
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw-method-UriRelative
*/
function UriRelative(documentLocation: string | (() => string)): typeof Uri;
@@ -136,11 +134,10 @@ declare global {
* file where they make use of named capture groups. That syntax isn't valid in JavaScript ES5,
* so the server-side strips these before delivering to the client.
*
- * @private
* @property {Object} parser
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Uri-static-property-parser
*/
- static parser: {
+ private static parser: {
strict: RegExp;
loose: RegExp;
};
@@ -148,11 +145,10 @@ declare global {
/**
* The order here matches the order of captured matches in the `parser` property regexes.
*
- * @private
* @property {string[]} properties
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Uri-static-property-properties
*/
- static properties: [
+ private static properties: [
"protocol",
"user",
"password",
@@ -185,7 +181,7 @@ declare global {
/**
* Clone this URI
*
- * @return {Uri} New URI object with same properties
+ * @returns {Uri} New URI object with same properties
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Uri-method-clone
*/
clone(): Uri;
@@ -193,9 +189,9 @@ declare global {
/**
* Extend the query section of the URI with new parameters.
*
- * @param {Object} parameters Query parameters to add to ours (or to override ours with) as an
+ * @param {QueryParams} parameters Query parameters to add to ours (or to override ours with) as an
* object
- * @return {Uri} This URI object
+ * @returns {Uri} This URI object
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Uri-method-extend
*/
extend(parameters: QueryParams): Uri;
@@ -205,7 +201,7 @@ declare global {
*
* In most real-world URLs this is simply the hostname, but the definition of 'authority' section is more general.
*
- * @return {string}
+ * @returns {string}
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Uri-method-getAuthority
*/
getAuthority(): string;
@@ -213,7 +209,7 @@ declare global {
/**
* Get host and port section of a URI.
*
- * @return {string}
+ * @returns {string}
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Uri-method-getHostPort
*/
getHostPort(): string;
@@ -223,7 +219,7 @@ declare global {
*
* Does not preserve the original order of arguments passed in the URI. Does handle escaping.
*
- * @return {string}
+ * @returns {string}
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Uri-method-getQueryString
*/
getQueryString(): string;
@@ -231,7 +227,7 @@ declare global {
/**
* Get everything after the authority section of the URI.
*
- * @return {string}
+ * @returns {string}
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Uri-method-getRelativePath
*/
getRelativePath(): string;
@@ -239,7 +235,7 @@ declare global {
/**
* Get user and password section of a URI.
*
- * @return {string}
+ * @returns {string}
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Uri-method-getUserInfo
*/
getUserInfo(): string;
@@ -255,7 +251,7 @@ declare global {
* web2017-polyfills, which loads a polyfill if needed) in contexts where the fragment
* is important.
*
- * @return {string} The URI string
+ * @returns {string} The URI string
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Uri-method-toString
*/
toString(): `${string}://${string}`;
@@ -263,13 +259,12 @@ declare global {
/**
* Parse a string and set our properties accordingly.
*
- * @private
* @param {string} str URI, see constructor.
* @param {Object} options See constructor.
* @throws {Error} when the query string or fragment contains an unknown % sequence
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Uri-method-parse
*/
- parse(str: string, options: Partial): void;
+ private parse(str: string, options: Partial): void;
/**
* Decode a url encoded value.
@@ -278,7 +273,7 @@ declare global {
* `+` with a space.
*
* @param {string} s String to decode
- * @return {string} Decoded string
+ * @returns {string} Decoded string
* @throws {Error} when the string contains an unknown % sequence
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Uri-static-method-decode
*/
@@ -292,7 +287,7 @@ declare global {
* mw.util.rawurlencode, except this also replaces spaces with `+`.
*
* @param {string} s String to encode
- * @return {string} Encoded string for URI
+ * @returns {string} Encoded string for URI
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Uri-static-method-encode
*/
static encode(s: string): string;
diff --git a/mw/config.d.ts b/mw/config.d.ts
index e9ec11e..e3ad45c 100644
--- a/mw/config.d.ts
+++ b/mw/config.d.ts
@@ -62,12 +62,6 @@ declare global {
* @see https://www.mediawiki.org/wiki/Manual:Interface/JavaScript#wgDBname
*/
wgDBname: string;
- /**
- * The wiki identifier. Should be preferred over wgDBname.
- *
- * @see https://www.mediawiki.org/wiki/Manual:Interface/JavaScript#wgWikiID
- */
- wgWikiID: string;
/**
* Root path used for extension static assets (e.g. images). Append '/' then the name of the extension to get the root path for a given extension.
*
@@ -116,6 +110,7 @@ declare global {
* @see https://www.mediawiki.org/wiki/Manual:Interface/JavaScript#wgSiteName
*/
wgSiteName: string;
+ wgUrlProtocols: string;
/**
* If a wiki has language variants (such as the Chinese and the Serbian Wikipedias), set to a path beginning at the root for language variants other than wgContentLanguage. The path contains two placeholders: "$1" is to be replaced by the page title, and "$2" is to be replaced by the language code of the language variant (e.g. "zh-tw"). If the wiki does not have language variants, set to false. See also $wgVariantArticlePath.
*
@@ -128,6 +123,12 @@ declare global {
* @see https://www.mediawiki.org/wiki/Manual:Interface/JavaScript#wgVersion
*/
wgVersion: string;
+ /**
+ * The wiki identifier. Should be preferred over wgDBname.
+ *
+ * @see https://www.mediawiki.org/wiki/Manual:Interface/JavaScript#wgWikiID
+ */
+ wgWikiID: string;
/**
* The action performed, e.g. "edit" for edit pages, or "view" for page views. See Manual:Parameters to index.php#Actions.
*
@@ -351,7 +352,6 @@ declare global {
* @see https://www.mediawiki.org/wiki/Manual:Interface/JavaScript#wgDiffNewId
*/
wgDiffNewId: number;
- wgUrlProtocols: string;
[key: string]: unknown; // more config keys can be added by extensions
}>;
}
diff --git a/mw/cookie.d.ts b/mw/cookie.d.ts
index 847fcdc..02feee3 100644
--- a/mw/cookie.d.ts
+++ b/mw/cookie.d.ts
@@ -13,8 +13,8 @@ declare global {
*
* @param {string} key The key for the cookie
* @param {string} [prefix] The prefix of the key. If undefined or null, `$wgCookiePrefix` is used
- * @param {*} [defaultValue] A value to return if the cookie does not exist
- * @returns {*} If the cookie exists, the value of the cookie, otherwise `defaultValue`
+ * @param {Mixed} [defaultValue] A value to return if the cookie does not exist
+ * @returns {Mixed} If the cookie exists, the value of the cookie, otherwise `defaultValue`
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.cookie-method-get
*/
function get(
@@ -29,8 +29,8 @@ declare global {
*
* @param {string} key The key for the cookie
* @param {string} [prefix] The prefix of the key. If undefined or null, `$wgCookiePrefix` is used
- * @param {*} defaultValue A value to return if the cookie does not exist
- * @returns {*} If the cookie exists, the value of the cookie, otherwise `defaultValue`
+ * @param {Mixed} [defaultValue] A value to return if the cookie does not exist
+ * @returns {Mixed} If the cookie exists, the value of the cookie, otherwise `defaultValue`
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.cookie-method-getCrossSite
*/
function getCrossSite(
@@ -59,7 +59,6 @@ declare global {
* @param {boolean} [options.secure] Whether or not to include the secure attribute (Does **not** use the wgCookieSecure configuration variable)
* @param {string} [options.sameSite] The `SameSite` flag of the cookie (case-insensitive; default is to omit the flag, which results in `Lax` on modern browsers). Set to `None` *and* set `secure` to `true` if the cookie needs to be visible on cross-domain requests
* @param {boolean} [options.sameSiteLegacy] If true, `SameSite` = `None` cookies will also be sent as non-`SameSite` cookies with an "ss0-" prefix, to work around old browsers interpreting the standard differently
- * @returns {void}
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.cookie-method-set
*/
// see https://stackoverflow.com/a/64932909 for
@@ -70,12 +69,12 @@ declare global {
| Date
| number
| Partial<{
- expires: Date | number;
- prefix: string;
domain: string;
+ expires: Date | number;
path: string;
- secure: boolean;
+ prefix: string;
sameSite: Lowercase extends SameSite ? SS : SameSite;
+ secure: boolean;
}>
): void;
}
diff --git a/mw/experiments.d.ts b/mw/experiments.d.ts
index 41fd4da..3dcbe37 100644
--- a/mw/experiments.d.ts
+++ b/mw/experiments.d.ts
@@ -31,13 +31,13 @@ declare global {
* // the A or B bucket. If the experiment were disabled, then the user would always be
* // assigned to the control bucket.
* {
- * name: 'My first experiment',
- * enabled: true,
- * buckets: {
- * control: 0.5
- * A: 0.25,
- * B: 0.25
- * }
+ * name: 'My first experiment',
+ * enabled: true,
+ * buckets: {
+ * control: 0.5
+ * A: 0.25,
+ * B: 0.25
+ * }
* }
* ```
*
@@ -50,7 +50,7 @@ declare global {
* that the user will be assigned to that bucket
* @param {string} token A token that uniquely identifies the user for the
* duration of the experiment
- * @return {string|undefined} The bucket
+ * @returns {string|undefined} The bucket
*/
function getBucket(experiment: Experiment, token: string): string | undefined;
}
diff --git a/mw/global.d.ts b/mw/global.d.ts
index 4600a5b..f4d3f94 100644
--- a/mw/global.d.ts
+++ b/mw/global.d.ts
@@ -9,7 +9,6 @@ declare global {
* Schedule a function to run once the page is ready (DOM loaded).
*
* @since 1.5.8
- * @member global
* @param {Function} fn
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/global-method-addOnloadHook
*/
@@ -22,19 +21,16 @@ declare global {
* be loaded and executed once.
*
* @since 1.12.2
- * @member global
* @param {string} title
- * @return {HTMLScriptElement|null} Script tag, or null if it was already imported before
+ * @returns {HTMLScriptElement|null} Script tag, or null if it was already imported before
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/global-method-importScript
*/
function importScript(title: string): HTMLScriptElement | null;
/**
* @since 1.12.2
- * @method importScriptURI
- * @member global
* @param {string} url
- * @return {HTMLScriptElement|null} Script tag, or null if it was already imported before
+ * @returns {HTMLScriptElement|null} Script tag, or null if it was already imported before
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/global-method-importScriptURI
*/
function importScriptURI(url: string): HTMLScriptElement | null;
@@ -43,19 +39,17 @@ declare global {
* Import a local CSS content page, for use by user scripts and site-wide scripts.
*
* @since 1.12.2
- * @member global
* @param {string} title
- * @return {HTMLLinkElement} Link tag
+ * @returns {HTMLLinkElement} Link tag
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/global-method-importStylesheet
*/
function importStylesheet(title: string): HTMLLinkElement;
/**
* @since 1.12.2
- * @member global
* @param {string} url
* @param {string} media
- * @return {HTMLLinkElement} Link tag
+ * @returns {HTMLLinkElement} Link tag
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/global-method-importStylesheetURI
*/
function importStylesheetURI(url: string, media: string): HTMLLinkElement;
diff --git a/mw/hook.d.ts b/mw/hook.d.ts
index bf6b2fd..b7348e6 100644
--- a/mw/hook.d.ts
+++ b/mw/hook.d.ts
@@ -48,7 +48,6 @@ interface Hook {
* Register a hook handler.
*
* @param {...Function} handler Function to bind.
- * @chainable
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.hook-method-add
*/
add(...handler: Array<(...data: T) => any>): this;
@@ -56,8 +55,7 @@ interface Hook {
/**
* Call hook handlers with data.
*
- * @param {*} data
- * @chainable
+ * @param {Mixed} data
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.hook-method-fire
*/
fire(...data: T): this;
@@ -66,7 +64,6 @@ interface Hook {
* Unregister a hook handler.
*
* @param {...Function} handler Function to unbind.
- * @chainable
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.hook-method-remove
*/
remove(...handler: Array<(...data: T) => any>): this;
diff --git a/mw/html.d.ts b/mw/html.d.ts
index 6267200..289805d 100644
--- a/mw/html.d.ts
+++ b/mw/html.d.ts
@@ -26,7 +26,7 @@ declare global {
* - string: Text to be escaped.
* - null: The element is treated as void with short closing form, e.g. `
`.
* - this.Raw: The raw value is directly included.
- * @return {string} HTML
+ * @returns {string} HTML
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.html-method-element
*/
function element(
@@ -46,7 +46,7 @@ declare global {
* ```
*
* @param {string} s The string to escape
- * @return {string} HTML
+ * @returns {string} HTML
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.html-method-escape
*/
function escape(s: string): string;
diff --git a/mw/index.d.ts b/mw/index.d.ts
index f7f300e..9c68b8f 100644
--- a/mw/index.d.ts
+++ b/mw/index.d.ts
@@ -43,12 +43,16 @@ declare global {
* Empty object for third-party libraries, for cases where you don't
* want to add a new global, or the global is bad and needs containment
* or wrapping.
- *
- * @property {Object}
*/
const libs: any;
- // types for mw.widgets are out of scope!
+ /**
+ * OOUI widgets specific to MediaWiki
+ *
+ * types for mw.widgets are out of scope!
+ *
+ * @see https://doc.wikimedia.org/mediawiki-core/master/js/source/mediawiki.base.html#mw-property-libs
+ */
const widgets: any;
/**
@@ -59,7 +63,7 @@ declare global {
* @since 1.25
* @param {string} formatString Format string
* @param {...Mixed} parameters Values for $N replacements
- * @return {string} Formatted string
+ * @returns {string} Formatted string
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw-method-format
*/
function format(formatString: string, ...parameters: unknown[]): string;
@@ -71,7 +75,8 @@ declare global {
* floating-point values with microsecond precision that are guaranteed to be monotonic.
* On all other browsers, it will fall back to using `Date`.
*
- * @return {number} Current time
+ * @returns {number} Current time
+ * @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw-method-now
*/
function now(): number;
@@ -98,7 +103,6 @@ declare global {
* -
* [RAIL]: https://developers.google.com/web/fundamentals/performance/rail
*
- * @member mw
* @param {Function} callback
* @param {Object} [options]
* @param {number} [options.timeout] If set, the callback will be scheduled for
@@ -122,6 +126,7 @@ declare global {
*
* @param {string} topic Topic name
* @param {Object|number|string} [data] Data describing the event.
+ * @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw-method-track
*/
function track(topic: string, data?: object | number | string): void;
@@ -131,6 +136,7 @@ declare global {
* @private
* @param {string} topic Topic name
* @param {Object} data Data describing the event, encoded as an object; see {@link errorLogger.logError}
+ * @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw-method-trackError
*/
function trackError(topic: string, data: object): void;
diff --git a/mw/language.d.ts b/mw/language.d.ts
index 32bbe5e..f84829c 100644
--- a/mw/language.d.ts
+++ b/mw/language.d.ts
@@ -55,7 +55,6 @@ declare global {
* Information about month names in current UI language.
*
* @property {Object}
- * @member mw.language
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.language-property-months
*/
const months: {
@@ -92,7 +91,7 @@ declare global {
* See LanguageCode::bcp47 for the PHP implementation.
*
* @param {string} languageTag Well-formed language tag
- * @return {string}
+ * @returns {string}
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.language-method-bcp47
*/
function bcp47(languageTag: string): string;
@@ -106,7 +105,7 @@ declare global {
*
* @param {string} word
* @param {string} form
- * @return {string}
+ * @returns {string}
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.language-method-convertGrammar
*/
function convertGrammar(word: string, form: string): string;
@@ -116,7 +115,7 @@ declare global {
*
* @param {number} num Value to be converted
* @param {boolean} [integer=false] Whether to convert the return value to an integer
- * @return {number|string} Formatted number
+ * @returns {number|string} Formatted number
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.language-method-convertNumber
*/
function convertNumber(num: number, integer?: boolean): number | string;
@@ -127,7 +126,7 @@ declare global {
* @param {number} count Non-localized quantifier
* @param {Array} forms List of plural forms
* @param {Object} [explicitPluralForms] List of explicit plural forms
- * @return {string} Correct form for quantifier in this language
+ * @returns {string} Correct form for quantifier in this language
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.language-method-convertPlural
*/
function convertPlural(
@@ -140,7 +139,7 @@ declare global {
* Helper function to flip transformation tables.
*
* @param {...Object} tables Transformation tables
- * @return {Object}
+ * @returns {Object}
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.language-method-flipTransform
*/
function flipTransform>(
@@ -157,7 +156,7 @@ declare global {
*
* @param {string} gender 'male', 'female', or anything else for neutral.
* @param {Array} forms List of gender forms
- * @return {string}
+ * @returns {string}
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.language-method-gender
*/
function gender(gender: string, forms: [T?, T?, T?]): T;
@@ -170,7 +169,7 @@ declare global {
*
* @param {string} langCode
* @param {string} dataKey
- * @return {any} Value stored in the mw.Map (or `undefined` if there is no map for the
+ * @returns {Mixed} Value stored in the mw.Map (or `undefined` if there is no map for the
* specified langCode)
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.language-method-getData
*/
@@ -179,7 +178,7 @@ declare global {
/**
* Get the digit transform table for current UI language.
*
- * @return {Object|Array}
+ * @returns {Object|Array}
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.language-method-getDigitTransformTable
*/
function getDigitTransformTable(): string[] | Record;
@@ -187,7 +186,7 @@ declare global {
/**
* Get the language fallback chain for current UI language, including the language itself.
*
- * @return {string[]} List of language keys, e.g. `['pfl', de', 'en']`
+ * @returns {string[]} List of language keys, e.g. `['pfl', de', 'en']`
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.language-method-getFallbackLanguageChain
*/
function getFallbackLanguageChain(): string[];
@@ -195,7 +194,7 @@ declare global {
/**
* Get the language fallback chain for current UI language (not including the language itself).
*
- * @return {string[]} List of language keys, e.g. `['de', 'en']`
+ * @returns {string[]} List of language keys, e.g. `['de', 'en']`
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.language-method-getFallbackLanguages
*/
function getFallbackLanguages(): string[];
@@ -203,7 +202,7 @@ declare global {
/**
* Get the separator transform table for current UI language.
*
- * @return {Object|Array}
+ * @returns {Object|Array}
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.language-method-getSeparatorTransformTable
*/
function getSeparatorTransformTable(): string[] | Record;
@@ -214,7 +213,7 @@ declare global {
* See Language::listToText in languages/Language.php
*
* @param {string[]} list
- * @return {string}
+ * @returns {string}
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.language-method-listToText
*/
function listToText(list: string[]): string;
@@ -226,7 +225,7 @@ declare global {
*
* @param {string} langCode
* @param {string|Object} dataKey Key or object of key/values
- * @param {any} [value] Value for dataKey, omit if dataKey is an object
+ * @param {Mixed} [value] Value for dataKey, omit if dataKey is an object
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.language-method-setData
*/
function setData(langCode: string, dataKey: string, value: any): void;
@@ -246,7 +245,7 @@ declare global {
* @param {string} options.decimal The decimal separator. Defaults to: `'.'`.
* @param {string} options.group The group separator. Defaults to: `','`.
* @param {number|null} options.minimumGroupingDigits
- * @return {string}
+ * @returns {string}
*/
function commafyNumber(
value: number,
@@ -270,7 +269,7 @@ declare global {
* @param {number} size The length to pad to
* @param {string} [ch='0'] Character to pad with
* @param {boolean} [end=false] Adds padding at the end if true, otherwise pads at start
- * @return {string}
+ * @returns {string}
*/
function pad(text: string, size: number, ch?: string, end?: boolean): string;
@@ -280,7 +279,7 @@ declare global {
* @private
* @param {Array} forms Number of forms given to convertPlural
* @param {number} count Number of forms required
- * @return {Array} Padded array of forms
+ * @returns {Array} Padded array of forms
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.language-method-preConvertPlural
*/
function preConvertPlural(forms: string[], count: number): string[];
@@ -291,7 +290,7 @@ declare global {
* @private
* @param {string} str The string to replicate
* @param {number} num Number of times to replicate the string
- * @return {string}
+ * @returns {string}
*/
function replicate(str: string, num: number): string;
}
diff --git a/mw/loader.d.ts b/mw/loader.d.ts
index c473cfa..dccb866 100644
--- a/mw/loader.d.ts
+++ b/mw/loader.d.ts
@@ -31,7 +31,7 @@ interface ModuleRequire {
* Get the exported value of a module.
*
* @param moduleName Module name
- * @return Exported value
+ * @returns Exported value
*/
(moduleName: string): any;
}
@@ -87,7 +87,7 @@ declare global {
* @param {string} text CSS text
* @param {Node|null} [nextNode] The element where the style tag
* should be inserted before
- * @return {HTMLStyleElement} Reference to the created style element
+ * @returns {HTMLStyleElement} Reference to the created style element
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.loader-method-addStyleTag
*/
function addStyleTag(text: string, nextNode?: Node | null): HTMLStyleElement;
@@ -95,8 +95,7 @@ declare global {
/**
* Get the names of all registered ResourceLoader modules.
*
- * @member mw.loader
- * @return {string[]}
+ * @returns {string[]}
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.loader-method-getModuleNames
*/
function getModuleNames(): string[];
@@ -119,9 +118,8 @@ declare global {
* } );
* ```
*
- * @member mw.loader
* @param {string} url Script URL
- * @return {JQuery.Promise} Resolved when the script is loaded
+ * @returns {JQuery.Promise} Resolved when the script is loaded
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.loader-method-getScript
*/
function getScript(url: string): JQuery.Promise;
@@ -139,7 +137,7 @@ declare global {
* - `missing`: The module was requested but is not defined according to the server.
*
* @param {string} module Name of module
- * @return {string|null} The state, or null if the module (or its state) is not
+ * @returns {string|null} The state, or null if the module (or its state) is not
* in the registry.
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.loader-method-getState
*/
@@ -156,7 +154,7 @@ declare global {
* as '`[name]@[version]`". This version should match the requested version
* (from #batchRequest and #registry). This avoids race conditions (T117587).
*
- * - 1. {Function|Array|string|Object} [script] Module code. This can be a function,
+ * - 1. {ModuleScript} [script] Module code. This can be a function,
* a list of URLs to load via `