refactor: tighten TypeScript boundaries

This commit is contained in:
ajnart committed 2026-08-24 09:38:30 +02:00
1 parent ad0120fe01
commit 24e6e4a47d
38 files changed
+246 -190

No files matched your search

+3 -4
View File
@@ -74,10 +74,9 @@ const loadRegisteredWidgetModule = createRetryableLoader(
new Map<WidgetKind, () => Promise<RegisteredWidgetModule>>(objectEntries(widgetModuleLoaders)),
);
// ponytail: TypeScript cannot express a Map whose value depends on its key. This
// private assertion restores only the fixed shapes above; the manifest alignment
// test checks module.definition.kind. Its ceiling is runtime-only mismatch
// detection, so remove it if TypeScript gains dependent Map value types.
// ponytail: TypeScript cannot correlate a generic key with the matching value
// in a Map. The registry itself is checked against WidgetImports, so this
// assertion only restores that already-verified relationship after caching.
const correlateWidgetPromise = <TKind extends WidgetKind, TType extends keyof WidgetManifestValue<TKind>>(
_kind: TKind,
_type: TType,
@@ -425,9 +425,7 @@ export default function MediaServerWidget({
<Group gap={6} wrap="nowrap">
<IconVideo size="var(--mantine-font-size-xs)" style={{ flexShrink: 0 }} />
<Text size="sm" fw={500} style={{ whiteSpace: "nowrap" }}>
{(t as unknown as (key: string, params?: { count: number }) => string)("footer.streams", {
count: flatSessions.length,
})}
{t("footer.streams", { count: flatSessions.length })}
</Text>
{totalBitrateLabel && (isAdvanced || width >= 300) && (
<>
+1 -6
View File
@@ -60,11 +60,6 @@ import type * as vpn from "./vpn";
import type * as weather from "./weather";
import type * as wud from "./wud";
type WidgetModule = {
definition: unknown;
componentLoader: () => Promise<unknown>;
};
// Keep these imports explicit so Next.js and Turbopack can discover every widget
// module without loading any widget definition or component eagerly.
export const widgetModuleLoaders = {
@@ -127,7 +122,7 @@ export const widgetModuleLoaders = {
customApi: () => import("./custom-api"),
weather: () => import("./weather"),
wud: () => import("./wud"),
} satisfies Record<WidgetKind, () => Promise<WidgetModule>>;
} satisfies { [TKind in WidgetKind]: () => Promise<WidgetImports[TKind]> };
export type WidgetImports = {
clock: typeof clock;