From 911b21700c8c4c2623b21c976080004a490113aa Mon Sep 17 00:00:00 2001 From: Vikhyath Mondreti Date: Thu, 7 May 2026 01:13:24 -0700 Subject: [PATCH] fix(type-error): subblock migrations type error --- .../migrations/subblock-migrations.ts | 42 +++++++++++-------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/apps/sim/lib/workflows/migrations/subblock-migrations.ts b/apps/sim/lib/workflows/migrations/subblock-migrations.ts index 89e7cb629e..d796a01728 100644 --- a/apps/sim/lib/workflows/migrations/subblock-migrations.ts +++ b/apps/sim/lib/workflows/migrations/subblock-migrations.ts @@ -97,25 +97,31 @@ function migrateBlockSubblockIds( continue } - const oldEntry = result[oldId] + const oldEntry: unknown = result[oldId] const configuredType = blockConfig?.subBlocks?.find((config) => config.id === newId)?.type - result[newId] = isPlainRecord(oldEntry) - ? { - ...oldEntry, - id: newId, - type: - configuredType || - (typeof oldEntry.type === 'string' && oldEntry.type.length > 0 - ? oldEntry.type === 'unknown' - ? DEFAULT_SUBBLOCK_TYPE - : oldEntry.type - : DEFAULT_SUBBLOCK_TYPE), - } - : ({ - id: newId, - type: configuredType || DEFAULT_SUBBLOCK_TYPE, - value: oldEntry, - } as BlockState['subBlocks'][string]) + if (isPlainRecord(oldEntry)) { + const type = + configuredType || + (typeof oldEntry.type === 'string' && oldEntry.type.length > 0 + ? oldEntry.type === 'unknown' + ? DEFAULT_SUBBLOCK_TYPE + : oldEntry.type + : DEFAULT_SUBBLOCK_TYPE) + const value = Object.hasOwn(oldEntry, 'value') ? oldEntry.value : null + + result[newId] = { + ...oldEntry, + id: newId, + type: type as BlockState['subBlocks'][string]['type'], + value: value as BlockState['subBlocks'][string]['value'], + } + } else { + result[newId] = { + id: newId, + type: configuredType || DEFAULT_SUBBLOCK_TYPE, + value: oldEntry as BlockState['subBlocks'][string]['value'], + } + } delete result[oldId] }