Fix unsafe frontend casts and mark Task 18 done

This commit is contained in:
2026-04-19 18:25:32 +02:00
parent e6ee525e0f
commit d44a667592
4 changed files with 5 additions and 5 deletions

View File

@@ -408,6 +408,8 @@ Reference: `Docs/Refactoring.md` for full analysis of each issue.
**Docs changes needed:** None.
**Status:** Completed.
**Why this is needed:** `as unknown as T` is the TypeScript equivalent of `any` — it silences the type checker without any safety guarantee. If the actual runtime value does not match `T`, the error is deferred to a cryptic downstream failure. The `import type` issue is a code hygiene violation — it prevents tree-shaking tools from safely dropping type-only imports and misleads readers into thinking a type has a runtime value.
---

View File

@@ -73,8 +73,7 @@ export function useDashboardCountryData(
if (controller.signal.aborted) return;
setCountries(data.countries);
setCountryNames(data.country_names);
// MapBanItem and DashboardBanItem are structurally identical.
setBans(data.bans as DashboardBanItem[]);
setBans(data.bans);
setTotal(data.total);
})
.catch((err: unknown) => {

View File

@@ -14,8 +14,7 @@ import { useRunImport } from "../hooks/useBlocklist";
import { ImportResultDialog } from "./blocklists/ImportResultDialog";
export function BlocklistsPage(): React.JSX.Element {
const safeUseBlocklistStyles = useBlocklistStyles as unknown as () => { root: string };
const styles = safeUseBlocklistStyles();
const styles = useBlocklistStyles();
const { running, lastResult, error: importError, runNow } = useRunImport();
const [importResultOpen, setImportResultOpen] = useState(false);

View File

@@ -19,11 +19,11 @@ import {
Text,
Toolbar,
ToolbarButton,
TableColumnDefinition,
createTableColumn,
makeStyles,
tokens,
} from "@fluentui/react-components";
import type { TableColumnDefinition } from "@fluentui/react-components";
import {
ArrowCounterclockwiseRegular,
ChevronLeftRegular,