Added strict type checking to the project. (#236)

* Implement strict typing (WIP).

* changes

* Finish type checks

* Fix notification icon, matugen settings and update tsconfig.

* OSD Styling updates and added the ability to configure OSD duration.
This commit is contained in:
Jas Singh
2024-09-09 00:44:51 -07:00
committed by GitHub
parent 41dbc3829a
commit bb3b3dfdfb
56 changed files with 468 additions and 240 deletions

View File

@@ -1,3 +1,5 @@
import { layoutMap } from "customModules/kblayout/layouts";
export type KbLabelType = "layout" | "code";
export type KbIcon = "" | "󰌌" | "" | "󰬴" | "󰗊";
@@ -26,3 +28,6 @@ export type HyprctlDeviceLayout = {
touch: any[];
switches: any[];
};
export type LayoutKeys = keyof typeof layoutMap;
export type LayoutValues = typeof layoutMap[LayoutKeys];

View File

@@ -0,0 +1,9 @@
import { Binding } from "lib/utils";
export type InputHandlerEvents = {
onPrimaryClick?: Binding,
onSecondaryClick?: Binding,
onMiddleClick?: Binding,
onScrollUp?: Binding,
onScrollDown?: Binding,
}

10
lib/types/dropdownmenu.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
import { WindowProps } from "types/widgets/window";
export type DropdownMenuProps = {
name: string;
child: any;
layout?: string;
transition?: any;
exclusivity?: Exclusivity;
fixed?: boolean;
} & WindowProps;

3
lib/types/filechooser.d.ts vendored Normal file
View File

@@ -0,0 +1,3 @@
export type Config = {
[key: string]: string | number | boolean | object;
}

3
lib/types/mpris.d.ts vendored Normal file
View File

@@ -0,0 +1,3 @@
export type LoopStatus = 'none' | 'track' | 'playlist';
export type PlaybackStatus = 'playing' | 'paused' | 'stopped';

View File

@@ -1,3 +1,5 @@
import { WIFI_STATUS_MAP } from "globals/network";
export type AccessPoint = {
bssid: string | null;
address: string | null;
@@ -8,3 +10,5 @@ export type AccessPoint = {
frequency: number;
iconName: string | undefined;
}
export type WifiStatus = keyof typeof WIFI_STATUS_MAP;

View File

@@ -1,3 +1,5 @@
import icons from "modules/icons/index";
export interface NotificationArgs {
appName?: string;
body?: string;
@@ -9,3 +11,5 @@ export interface NotificationArgs {
timeout?: number;
transient?: boolean;
}
export type NotificationIcon = keyof typeof icons.notifications;

View File

@@ -1,6 +1,10 @@
import { Opt } from "lib/option";
import { Variable } from "types/variable";
export type RecursiveOptionsObject = {
[key: string]: RecursiveOptionsObject | Opt<string | number | boolean> | Opt<any>;
};
export type Unit = "imperial" | "metric";
export type PowerOptions = "sleep" | "reboot" | "logout" | "shutdown";
export type NotificationAnchor = "top" | "top right" | "top left" | "bottom" | "bottom right" | "bottom left" | "left" | "right";
@@ -117,3 +121,4 @@ type MatugenVariation =
| "vivid_3"
type MatugenTheme = "light" | "dark";

27
lib/types/popupwindow.d.ts vendored Normal file
View File

@@ -0,0 +1,27 @@
import { Widget } from "types/widgets/widget";
import { WindowProps } from "types/widgets/window";
import { Transition } from "./widget";
export type PopupWindowProps = {
name: string;
child: any;
layout?: Layouts;
transition?: any;
exclusivity?: Exclusivity;
} & WindowProps;
export type LayoutFunction = (
name: string,
child: Widget,
transition: Transition
) => {
center: () => Widget;
top: () => Widget;
"top-right": () => Widget;
"top-center": () => Widget;
"top-left": () => Widget;
"bottom-left": () => Widget;
"bottom-center": () => Widget;
"bottom-right": () => Widget;
};
export type Layouts = 'center' | 'top' | 'top-right' | 'top-center' | 'top-left' | 'bottom-left' | 'bottom-center' | 'bottom-right';

8
lib/types/powerprofiles.d.ts vendored Normal file
View File

@@ -0,0 +1,8 @@
import icons from "modules/icons/index";
import PowerProfiles from "types/service/powerprofiles.js"
export type PowerProfiles = InstanceType<typeof PowerProfiles>;
export type PowerProfile = "power-saver" | "balanced" | "performance";
export type PowerProfileObject = {
[key: string]: string;
}

3
lib/types/utils.d.ts vendored Normal file
View File

@@ -0,0 +1,3 @@
import { substitutes } from "lib/icons";
type SubstituteKeys = keyof typeof substitutes;

View File

@@ -1,3 +1,5 @@
import { weatherIcons } from "modules/icons/weather";
export type UnitType = "imperial" | "metric";
export type Weather = {
@@ -107,3 +109,10 @@ export type Location = {
localtime_epoch: number;
localtime: string;
}
export type TemperatureIconColorMap = {
[key: number]: string;
}
export type WeatherIconTitle = keyof typeof weatherIcons;
export type WeatherIcon = typeof weatherIcons[WeatherIconTitle];

View File

@@ -1,3 +1,6 @@
export type Exclusivity = 'normal' | 'ignore' | 'exclusive';
export type Anchor = "left" | "right" | "top" | "down";
export type Transition = "none" | "crossfade" | "slide_right" | "slide_left" | "slide_up" | "slide_down";
// Window
export type Layouts = 'center' | 'top' | 'top-right' | 'top-center' | 'top-left' | 'bottom-left' | 'bottom-center' | 'bottom-right';