From 559f781d9a0c73156c23e47147a978ec7ab810bd Mon Sep 17 00:00:00 2001 From: Chris Villa Date: Tue, 3 Sep 2024 19:01:03 +0100 Subject: [PATCH] refactor: simplify zone type forcing --- packages/core/lib/setup-zone.ts | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/packages/core/lib/setup-zone.ts b/packages/core/lib/setup-zone.ts index 95cc7d5564..8d256027ee 100644 --- a/packages/core/lib/setup-zone.ts +++ b/packages/core/lib/setup-zone.ts @@ -4,16 +4,6 @@ import { rootDroppableId } from "./root-droppable-id"; // Force 'zones' to always be present and non-undefined type WithZones = T & { zones: NonNullable }; -// Ensuring zones is non-undefined and part of the final type -function ensureZones( - data: UserData -): WithZones { - return { - ...data, - zones: data.zones || {}, - } as WithZones; -} - export const setupZone = ( data: UserData, zoneKey: string @@ -23,7 +13,10 @@ export const setupZone = ( } // Preprocess to ensure zones is not undefined - const newData = ensureZones(data); + const newData = { + ...data, + zones: data.zones || {}, + }; newData.zones[zoneKey] = newData.zones[zoneKey] || [];