From 9ad1f823879bec19c9eb40aadb6773f1ad663533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lev=20Z=20Kir=C3=A1ly?= Date: Wed, 22 Nov 2023 15:19:34 +0100 Subject: [PATCH] Fix WindowState type inconsistency #4 --- stores/use-windows-store.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/stores/use-windows-store.ts b/stores/use-windows-store.ts index 39f447b..c11dae2 100644 --- a/stores/use-windows-store.ts +++ b/stores/use-windows-store.ts @@ -101,6 +101,7 @@ const WindowState = z.object({ title: z.string(), params: z.unknown(), }); +type WindowStateInferred = z.infer; export const useWindowsStore = defineStore("windows", () => { const registry = ref(new Map()); @@ -124,9 +125,9 @@ export const useWindowsStore = defineStore("windows", () => { return; } - let windowStates: Array; + let windowStates: Array; try { - windowStates = JSON.parse(route.query.w as string) as Array; + windowStates = JSON.parse(route.query.w as string) as Array; } catch (e) { toasts.addToast({ title: "Error: JSON parse failed", description: e.message }); await initializeScreen(); @@ -264,7 +265,7 @@ export const useWindowsStore = defineStore("windows", () => { }); function serializeWindowStates() { - const windowStates: Array = []; + const windowStates: Array = []; registry.value.forEach((w) => { windowStates.push({ x: w.winbox.x as number, @@ -274,7 +275,7 @@ export const useWindowsStore = defineStore("windows", () => { kind: w.kind, title: w.winbox.title, params: w.params, - } as z.infer); + } as WindowStateInferred); }); console.log(JSON.stringify(windowStates)); return windowStates;