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,35 +1,43 @@
import { Weather } from "lib/types/weather.js";
import { Weather, WeatherIcon, WeatherIconTitle } from "lib/types/weather.js";
import { Variable } from "types/variable.js";
import { weatherIcons } from "modules/icons/weather.js";
import { isValidWeatherIconTitle } from "globals/weather";
export const HourlyIcon = (theWeather: Variable<Weather>, getNextEpoch: any) => {
const getIconQuery = (wthr: Weather) => {
const getIconQuery = (wthr: Weather): WeatherIconTitle => {
const nextEpoch = getNextEpoch(wthr);
const weatherAtEpoch = wthr.forecast.forecastday[0].hour.find(
(h) => h.time_epoch === nextEpoch,
);
let iconQuery = weatherAtEpoch?.condition.text
if (weatherAtEpoch === undefined) {
return "warning";
}
let iconQuery = weatherAtEpoch.condition.text
.trim()
.toLowerCase()
.replaceAll(" ", "_")
|| "warning"
;
.replaceAll(" ", "_");
if (!weatherAtEpoch?.is_day && iconQuery === "partly_cloudy") {
iconQuery = "partly_cloudy_night";
}
return iconQuery;
if (isValidWeatherIconTitle(iconQuery)) {
return iconQuery;
} else {
return "warning";
}
}
return Widget.Box({
hpack: "center",
child: theWeather.bind("value").as((w) => {
let weatherIcn = "-";
let weatherIcn: WeatherIcon;
const iconQuery = getIconQuery(w);
weatherIcn = weatherIcons[iconQuery];
weatherIcn = weatherIcons[iconQuery] || weatherIcons["warning"];
return Widget.Label({
hpack: "center",
class_name: "hourly-weather-icon txt-icon",