From fcec0b046a7f62e967d32ae16ef727fa13b02b84 Mon Sep 17 00:00:00 2001 From: Anton Tranelis Date: Tue, 19 Aug 2025 20:20:06 +0200 Subject: [PATCH] fix: resolve TypeScript undefined data errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add non-null assertions for result.data in conditional blocks - TypeScript now properly recognizes data is defined after success check - All linting and TypeScript errors resolved 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- lib/src/Components/Map/hooks/useSelectPosition.tsx | 6 +++--- lib/src/Components/Profile/itemFunctions.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/src/Components/Map/hooks/useSelectPosition.tsx b/lib/src/Components/Map/hooks/useSelectPosition.tsx index c0e0b8e0..98c2c8e4 100644 --- a/lib/src/Components/Map/hooks/useSelectPosition.tsx +++ b/lib/src/Components/Map/hooks/useSelectPosition.tsx @@ -140,7 +140,7 @@ function useSelectPositionManager(): { if (result.success && result.data) { // Find the layer object by ID from server response - const layer = layers.find((l) => l.id === (result.data.layer as unknown as string)) + const layer = layers.find((l) => l.id === (result.data!.layer as unknown as string)) const itemWithLayer = { ...result.data, layer } updateItem(itemWithLayer) await linkItem(updatedItem.id) @@ -176,7 +176,7 @@ function useSelectPositionManager(): { if (result.success && result.data) { // Find the layer object by ID from server response - const layer = layers.find((l) => l.id === (result.data.layer as unknown as string)) + const layer = layers.find((l) => l.id === (result.data!.layer as unknown as string)) const itemWithLayer = { ...result.data, layer } updateItem(itemWithLayer) } @@ -202,7 +202,7 @@ function useSelectPositionManager(): { if (result.success && result.data) { // Find the layer object by ID from server response - const layer = layers.find((l) => l.id === (result.data.layer as unknown as string)) + const layer = layers.find((l) => l.id === (result.data!.layer as unknown as string)) const itemWithLayer = { ...result.data, layer } updateItem(itemWithLayer) } diff --git a/lib/src/Components/Profile/itemFunctions.ts b/lib/src/Components/Profile/itemFunctions.ts index 3129503c..44e5940c 100644 --- a/lib/src/Components/Profile/itemFunctions.ts +++ b/lib/src/Components/Profile/itemFunctions.ts @@ -105,7 +105,7 @@ export const submitNewItem = async ( if (result.success && result.data) { // Find the layer object by ID from server response - const layerForItem = layers.find((l) => l.id === result.data.layer) || layer + const layerForItem = layers.find((l) => l.id === result.data!.layer) || layer const itemWithLayer = { ...result.data, layer: layerForItem } addItem(itemWithLayer) await linkItem(uuid)