diff --git a/jquery/confirmable.d.ts b/jquery/confirmable.d.ts index 3c35d19..78c3f7b 100644 --- a/jquery/confirmable.d.ts +++ b/jquery/confirmable.d.ts @@ -21,58 +21,65 @@ declare global { * $( 'button' ).confirmable(); * } ); * ``` - * @see https://doc.wikimedia.org/mediawiki-core/master/js/jQueryPlugins.html#.confirmable + * @see https://doc.wikimedia.org/mediawiki-core/master/js/module-jquery.confirmable.html#.$.fn.confirmable */ confirmable: Confirmable; } } +// make all properties required, replacing optional values with undefined +type RequiredOrUndefined = { + [P in keyof Required]: undefined extends T[P] ? T[P] | undefined : T[P]; +}; + interface Confirmable { /** - * @param {Partial} [options] + * @param {Options} [options] */ - (options?: Partial): this; + (options?: Options): this; /** * Default options. Overridable primarily for internationalisation handling. */ - defaultOptions: Options; + defaultOptions: RequiredOptions; - handler(event: JQuery.Event, options: Options): void; + handler(event: JQuery.Event, options: RequiredOptions): void; } +type RequiredOptions = Required & { i18n: RequiredOrUndefined }; + interface Options { /** * Optional selector used for jQuery event delegation. */ - delegate: string | null; + delegate?: string | null; /** * Events to hook to. */ - events: string; + events?: string; /** * Text to use for interface elements. */ - i18n: I18N; + i18n?: I18N; /** * Callback to fire when preparing confirmable buttons. It is fired separately for the 'Yes' and 'No' button. * Receives the button jQuery object as the first parameter and 'yes' or 'no' as the second. */ - buttonCallback($button: JQuery): JQuery; + buttonCallback?($button: JQuery): JQuery; /** * Callback to fire when the action is confirmed (user clicks the 'Yes' button). */ - handler: ((event: JQuery.Event) => void) | null; + handler?: ((event: JQuery.Event) => void) | null; /** * Callback to fire when preparing confirmable interface. * Receives the interface jQuery object as the only parameter. */ - wrapperCallback($interface: JQuery): JQuery; + wrapperCallback?($interface: JQuery): JQuery; } // tslint:disable-next-line:interface-name @@ -92,7 +99,7 @@ interface I18N { /** * Optional title text to use for the 'No' button. */ - noTitle: string | undefined; + noTitle?: string | undefined; /** * Word separator to place between the three text messages. @@ -109,7 +116,7 @@ interface I18N { /** * Optional title text to use for the 'Yes' button. */ - yesTitle: string | undefined; + yesTitle?: string | undefined; } export {}; diff --git a/jquery/cookie.d.ts b/jquery/cookie.d.ts index 81b15d2..6c0d3f9 100644 --- a/jquery/cookie.d.ts +++ b/jquery/cookie.d.ts @@ -16,7 +16,7 @@ declare global { * @param {mw.cookie.CookieOptions} [options] * @returns {string|Object} The current value (if getting a cookie), or an internal `document.cookie` * expression (if setting or removing). - * @see https://doc.wikimedia.org/mediawiki-core/master/js/jQueryPlugins.html#.cookie + * @see https://doc.wikimedia.org/mediawiki-core/master/js/module-mediawiki.cookie.html#.$.cookie */ cookie(key: string, value: string | null, options?: mw.cookie.CookieOptions): string; cookie(key: string): unknown; @@ -34,7 +34,7 @@ declare global { * @param {string} key * @param {mw.cookie.CookieOptions} options * @returns {boolean} True if the cookie previously existed - * @see https://doc.wikimedia.org/mediawiki-core/master/js/jQueryPlugins.html#.removeCookie + * @see https://doc.wikimedia.org/mediawiki-core/master/js/module-mediawiki.cookie.html#.$.removeCookie */ removeCookie(key: string, options: mw.cookie.CookieOptions): boolean; } diff --git a/jquery/highlightText.d.ts b/jquery/highlightText.d.ts index 732a36a..05df7cc 100644 --- a/jquery/highlightText.d.ts +++ b/jquery/highlightText.d.ts @@ -19,7 +19,7 @@ declare global { * @param {string} matchString String to match * @param {Options} [options] * @returns {JQuery} - * @see https://doc.wikimedia.org/mediawiki-core/master/js/jQueryPlugins.html#.highlightText + * @see https://doc.wikimedia.org/mediawiki-core/master/js/module-jquery.highlightText.html#.$.fn.highlightText */ highlightText(matchString: string, options?: Options): this; } diff --git a/jquery/lengthLimit.d.ts b/jquery/lengthLimit.d.ts index 5bebcf4..6154d2a 100644 --- a/jquery/lengthLimit.d.ts +++ b/jquery/lengthLimit.d.ts @@ -15,7 +15,7 @@ declare global { * @param {number} byteLimit Number of bytes the value may be in size. * @param {FilterFunction} [filterFunction] Function to call on the string before assessing the length. * @returns {TrimResult} - * @see https://doc.wikimedia.org/mediawiki-core/master/js/jQueryPlugins.html#.trimByteLength + * @see https://doc.wikimedia.org/mediawiki-core/master/js/module-jquery.lengthLimit.html#.'$.fn.trimByteLength' */ trimByteLength( safeVal: string, @@ -40,7 +40,7 @@ declare global { * called with fetched value as argument. * @param {FilterFunction} [filterFunction] Function to call on the string before assessing the length. * @returns {JQuery} - * @see https://doc.wikimedia.org/mediawiki-core/master/js/jQueryPlugins.html#.byteLimit + * @see https://doc.wikimedia.org/mediawiki-core/master/js/module-jquery.lengthLimit.html#.$.fn.byteLimit */ byteLimit(limit: number, filterFunction?: FilterFunction): this; byteLimit(filterFunction?: FilterFunction): this; @@ -62,7 +62,7 @@ declare global { * called with fetched value as argument. * @param {FilterFunction} [filterFunction] Function to call on the string before assessing the length. * @returns {JQuery} - * @see https://doc.wikimedia.org/mediawiki-core/master/js/jQueryPlugins.html#.codePointLimit + * @see https://doc.wikimedia.org/mediawiki-core/master/js/module-jquery.lengthLimit.html#.$.fn.codePointLimit */ codePointLimit(limit: number, filterFunction?: FilterFunction): this; codePointLimit(filterFunction?: FilterFunction): this; diff --git a/jquery/makeCollapsible.d.ts b/jquery/makeCollapsible.d.ts index 803436c..64e48ac 100644 --- a/jquery/makeCollapsible.d.ts +++ b/jquery/makeCollapsible.d.ts @@ -18,7 +18,7 @@ declare global { * ``` * @param {Options} [options] * @returns {JQuery} - * @see https://doc.wikimedia.org/mediawiki-core/master/js/jQueryPlugins.html#.makeCollapsible + * @see https://doc.wikimedia.org/mediawiki-core/master/js/module-jquery.makeCollapsible.html#.$.fn.makeCollapsible */ makeCollapsible(options?: Options): this; } diff --git a/jquery/spinner.d.ts b/jquery/spinner.d.ts index 41cce1e..29f48d7 100644 --- a/jquery/spinner.d.ts +++ b/jquery/spinner.d.ts @@ -69,6 +69,11 @@ declare global { type Size = "large" | "small"; type Type = "block" | "inline"; +/** + * Options for {@link JQuery.injectSpinner}. + * + * @see https://doc.wikimedia.org/mediawiki-core/master/js/jQueryPlugins.html#~SpinnerOpts + */ interface Options { /** * If given, spinner will be given an id of "mw-spinner-{id}". diff --git a/jquery/updateTooltipAccessKeys.d.ts b/jquery/updateTooltipAccessKeys.d.ts index 8b4c18b..0666398 100644 --- a/jquery/updateTooltipAccessKeys.d.ts +++ b/jquery/updateTooltipAccessKeys.d.ts @@ -22,7 +22,7 @@ interface TooltipAccessKeys { * } ); * ``` * @returns {JQuery} - * @see https://doc.wikimedia.org/mediawiki-core/master/js/jQueryPlugins.html#.updateTooltipAccessKeys + * @see https://doc.wikimedia.org/mediawiki-core/REL1_42/js/jQueryPlugins.html#.updateTooltipAccessKeys */ (): This;