From 49ad52dee0ca6d052f9e75ce318c6bd0e292c637 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20LES=C3=89N=C3=89CHAL?= Date: Tue, 28 May 2024 16:07:22 +0200 Subject: [PATCH] Sort members for consistency, missed small interfaces from previous commits https://github.com/wikimedia-gadgets/types-mediawiki/pull/42/commits/0680f0185fb3a1464d15c34166835d61d04c9f6b Also simplify `RequiredOrUndefined` type --- jquery/client.d.ts | 4 ++-- jquery/collapsibleTabs.d.ts | 18 +++++++++--------- jquery/confirmable.d.ts | 5 +++-- jquery/textSelection.d.ts | 24 ++++++++++++------------ mw/Api.d.ts | 2 +- mw/Uri.d.ts | 2 +- mw/config.d.ts | 2 +- mw/experiments.d.ts | 8 ++++---- mw/hook.d.ts | 12 ++++++------ mw/index.d.ts | 2 +- mw/inspect.d.ts | 2 +- mw/notification.d.ts | 4 ++-- 12 files changed, 43 insertions(+), 42 deletions(-) diff --git a/jquery/client.d.ts b/jquery/client.d.ts index b1da981..1f03fba 100644 --- a/jquery/client.d.ts +++ b/jquery/client.d.ts @@ -128,8 +128,8 @@ interface Client { } export interface ClientNavigator { - userAgent: string; platform: string; + userAgent: string; } type ClientProfileName = @@ -157,9 +157,9 @@ type ClientSupportMap = | Record<"ltr" | "rtl", UndirectedClientSupportMap>; interface ClientProfile { - name: ClientProfileName; layout: "edge" | "gecko" | "khtml" | "presto" | "trident" | "webkit"; layoutVersion: number; + name: ClientProfileName; platform: "ipad" | "iphone" | "linux" | "mac" | "solaris" | "win"; version: string; versionBase: string; diff --git a/jquery/collapsibleTabs.d.ts b/jquery/collapsibleTabs.d.ts index 05165d2..4a2af39 100644 --- a/jquery/collapsibleTabs.d.ts +++ b/jquery/collapsibleTabs.d.ts @@ -22,10 +22,6 @@ declare global { * @see https://doc.wikimedia.org/mediawiki-skins-Vector/master/js/js/CollapsibleTabsOptions.html */ interface CollapsibleTabsOptions { - /** - * Optional tab selector. Defaults to `#p-views ul`. - */ - expandedContainer: string; /** * Optional menu item selector. Defaults to `#p-cactions ul`. */ @@ -34,12 +30,16 @@ interface CollapsibleTabsOptions { * Optional selector for tabs that are collapsible. Defaults to `li.collapsible`. */ collapsible: string; - shifting: boolean; + /** + * Optional tab selector. Defaults to `#p-views ul`. + */ + expandedContainer: string; expandedWidth: number; - - expandCondition(eleWidth: number): boolean; + shifting: boolean; collapseCondition(): boolean; + + expandCondition(eleWidth: number): boolean; } interface CollapsibleTabsStatic { @@ -48,6 +48,8 @@ interface CollapsibleTabsStatic { addData($collapsible: JQuery): void; + calculateTabDistance(): number; + getSettings($collapsible: JQuery): CollapsibleTabsOptions; handleResize(): void; @@ -55,8 +57,6 @@ interface CollapsibleTabsStatic { moveToCollapsed($moving: JQuery): void; moveToExpanded($moving: JQuery): void; - - calculateTabDistance(): number; } interface CollapsibleTabs extends CollapsibleTabsStatic, CollapsibleTabsOptions {} diff --git a/jquery/confirmable.d.ts b/jquery/confirmable.d.ts index 7a30e81..20843b9 100644 --- a/jquery/confirmable.d.ts +++ b/jquery/confirmable.d.ts @@ -27,9 +27,10 @@ declare global { } } -// make all properties required, replacing optional values with undefined +// make all properties required, replacing optional values with undefined, +// whether "exactOptionalPropertyTypes" is enabled or not. type RequiredOrUndefined = { - [P in keyof Required]: undefined extends T[P] ? T[P] | undefined : T[P]; + [P in keyof Required]: T[P]; }; interface Confirmable { diff --git a/jquery/textSelection.d.ts b/jquery/textSelection.d.ts index 0859497..1614837 100644 --- a/jquery/textSelection.d.ts +++ b/jquery/textSelection.d.ts @@ -152,9 +152,9 @@ declare global { interface TextSelectionEncapsulateOptions { /** - * Text to insert before the cursor/selection. + * Put the inserted text on a line of its own. Defaults to false. */ - pre?: string; + ownline?: boolean; /** * Text to insert between pre and post and select afterwards. */ @@ -164,29 +164,29 @@ interface TextSelectionEncapsulateOptions { */ post?: string; /** - * Put the inserted text on a line of its own. Defaults to false. + * Text to insert before the cursor/selection. */ - ownline?: boolean; + pre?: string; /** * If there is a selection, replace it with peri instead of leaving it alone. Defaults to false. */ replace?: boolean; /** - * Select the peri text if it was inserted (but not if there was a selection and replace==false, or if splitlines==true). Defaults to true. - */ - selectPeri?: boolean; - /** - * If multiple lines are selected, encapsulate each line individually. Defaults to false. + * Position to end selection at. Defaults to the position to start setection at. */ - splitlines?: boolean; + selectionEnd?: number; /** * Position to start selection at. */ selectionStart?: number; /** - * Position to end selection at. Defaults to the position to start setection at. + * Select the peri text if it was inserted (but not if there was a selection and replace==false, or if splitlines==true). Defaults to true. */ - selectionEnd?: number; + selectPeri?: boolean; + /** + * If multiple lines are selected, encapsulate each line individually. Defaults to false. + */ + splitlines?: boolean; } interface GetCaretPositionOptions { diff --git a/mw/Api.d.ts b/mw/Api.d.ts index b19ecc8..18d8679 100644 --- a/mw/Api.d.ts +++ b/mw/Api.d.ts @@ -48,9 +48,9 @@ interface EditNoChangeResult extends EditSuccessResult { } interface EditChangedResult extends EditSuccessResult { - oldrevid: number; newrevid: number; newtimestamp: string; + oldrevid: number; } // type alias to fix #45 diff --git a/mw/Uri.d.ts b/mw/Uri.d.ts index d9ab9d7..4647dfc 100644 --- a/mw/Uri.d.ts +++ b/mw/Uri.d.ts @@ -1,8 +1,8 @@ export type QueryParams = Record; interface UriParser { - strict: RegExp; loose: RegExp; + strict: RegExp; } declare global { diff --git a/mw/config.d.ts b/mw/config.d.ts index ffbcb27..c28faf2 100644 --- a/mw/config.d.ts +++ b/mw/config.d.ts @@ -388,8 +388,8 @@ interface LimitReport { } interface LimitReportValue { - value: number; limit: number; + value: number; } export {}; diff --git a/mw/experiments.d.ts b/mw/experiments.d.ts index 7e1e443..fe92203 100644 --- a/mw/experiments.d.ts +++ b/mw/experiments.d.ts @@ -1,16 +1,16 @@ interface Experiment { /** - * The name of the experiment + * A map of bucket name to probability that the user will be assigned to that bucket */ - name: string; + buckets: Record; /** * Whether the experiment is enabled. If the experiment is disabled, then the user is always assigned to the control bucket */ enabled: boolean; /** - * A map of bucket name to probability that the user will be assigned to that bucket + * The name of the experiment */ - buckets: Record; + name: string; } declare global { diff --git a/mw/hook.d.ts b/mw/hook.d.ts index b4e0d54..3fc6f27 100644 --- a/mw/hook.d.ts +++ b/mw/hook.d.ts @@ -75,14 +75,14 @@ interface PostEditData { * String for plain text, use array or jQuery object to pass actual nodes. */ message?: string | JQuery | HTMLElement[]; - /** - * User that made the edit. - */ - user?: string | User; /** * Whether a temporary user account was created. */ tempUserCreated?: boolean; + /** + * User that made the edit. + */ + user?: string | User; } interface SearchIndex { @@ -90,10 +90,10 @@ interface SearchIndex { } interface SearchIndexEntry { - $highlight: JQuery; $field: JQuery; - $wrapper: JQuery; + $highlight: JQuery; $tabPanel: JQuery; + $wrapper: JQuery; } interface EditRecovery { diff --git a/mw/index.d.ts b/mw/index.d.ts index 97c4ef2..f86bc5f 100644 --- a/mw/index.d.ts +++ b/mw/index.d.ts @@ -57,8 +57,8 @@ interface ErrorAnalyticEventData extends ObjectAnalyticEventData { } interface AnalyticEvent { - topic: string; data: AnalyticEventData; + topic: string; } interface AnalyticEventCallback { diff --git a/mw/inspect.d.ts b/mw/inspect.d.ts index c6edbe5..3d7c2df 100644 --- a/mw/inspect.d.ts +++ b/mw/inspect.d.ts @@ -70,8 +70,8 @@ interface ResourceLoaderReportMap { } interface Dependency { - requires: string[]; requiredBy: string[]; + requires: string[]; } declare global { diff --git a/mw/notification.d.ts b/mw/notification.d.ts index 8eb53a0..de8be0c 100644 --- a/mw/notification.d.ts +++ b/mw/notification.d.ts @@ -14,8 +14,8 @@ interface Notification { isPaused: boolean; options: mw.notification.NotificationOptions; timeout: { - set: typeof setTimeout; clear: typeof clearTimeout; + set: typeof setTimeout; }; /** @@ -92,8 +92,8 @@ declare global { * @private */ const autoHideSeconds: { - short: number; long: number; + short: number; }; /**