Skip to content

Commit

Permalink
Sort members
Browse files Browse the repository at this point in the history
for consistency, missed small interfaces from previous commits wikimedia-gadgets@0680f01
Also simplify `RequiredOrUndefined` type
  • Loading branch information
Adrien LESÉNÉCHAL committed May 28, 2024
1 parent 21e20cc commit 49ad52d
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 42 deletions.
4 changes: 2 additions & 2 deletions jquery/client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ interface Client {
}

export interface ClientNavigator {
userAgent: string;
platform: string;
userAgent: string;
}

type ClientProfileName =
Expand Down Expand Up @@ -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;
Expand Down
18 changes: 9 additions & 9 deletions jquery/collapsibleTabs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
*/
Expand All @@ -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 {
Expand All @@ -48,15 +48,15 @@ interface CollapsibleTabsStatic {

addData($collapsible: JQuery): void;

calculateTabDistance(): number;

getSettings($collapsible: JQuery): CollapsibleTabsOptions;

handleResize(): void;

moveToCollapsed($moving: JQuery): void;

moveToExpanded($moving: JQuery): void;

calculateTabDistance(): number;
}

interface CollapsibleTabs extends CollapsibleTabsStatic, CollapsibleTabsOptions {}
Expand Down
5 changes: 3 additions & 2 deletions jquery/confirmable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> = {
[P in keyof Required<T>]: undefined extends T[P] ? T[P] | undefined : T[P];
[P in keyof Required<T>]: T[P];
};

interface Confirmable {
Expand Down
24 changes: 12 additions & 12 deletions jquery/textSelection.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion mw/Api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mw/Uri.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export type QueryParams = Record<string, string | number | boolean | null | undefined>;

interface UriParser {
strict: RegExp;
loose: RegExp;
strict: RegExp;
}

declare global {
Expand Down
2 changes: 1 addition & 1 deletion mw/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,8 @@ interface LimitReport {
}

interface LimitReportValue {
value: number;
limit: number;
value: number;
}

export {};
8 changes: 4 additions & 4 deletions mw/experiments.d.ts
Original file line number Diff line number Diff line change
@@ -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<string, number>;
/**
* 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<string, number>;
name: string;
}

declare global {
Expand Down
12 changes: 6 additions & 6 deletions mw/hook.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,25 +75,25 @@ 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 {
[k: string]: SearchIndexEntry[];
}

interface SearchIndexEntry {
$highlight: JQuery;
$field: JQuery;
$wrapper: JQuery;
$highlight: JQuery;
$tabPanel: JQuery;
$wrapper: JQuery;
}

interface EditRecovery {
Expand Down
2 changes: 1 addition & 1 deletion mw/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ interface ErrorAnalyticEventData extends ObjectAnalyticEventData {
}

interface AnalyticEvent {
topic: string;
data: AnalyticEventData;
topic: string;
}

interface AnalyticEventCallback {
Expand Down
2 changes: 1 addition & 1 deletion mw/inspect.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ interface ResourceLoaderReportMap {
}

interface Dependency {
requires: string[];
requiredBy: string[];
requires: string[];
}

declare global {
Expand Down
4 changes: 2 additions & 2 deletions mw/notification.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ interface Notification {
isPaused: boolean;
options: mw.notification.NotificationOptions;
timeout: {
set: typeof setTimeout;
clear: typeof clearTimeout;
set: typeof setTimeout;
};

/**
Expand Down Expand Up @@ -92,8 +92,8 @@ declare global {
* @private
*/
const autoHideSeconds: {
short: number;
long: number;
short: number;
};

/**
Expand Down

0 comments on commit 49ad52d

Please sign in to comment.