From 8624997f4c371fb853159605a5fc81a4289baa99 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 14 Jan 2025 11:14:30 +0100 Subject: [PATCH] Fix types --- packages/builder/src/helpers/duplicate.ts | 12 +++++++++--- packages/builder/src/stores/builder/rowActions.ts | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/builder/src/helpers/duplicate.ts b/packages/builder/src/helpers/duplicate.ts index 4816bcfd7b..35beb4df38 100644 --- a/packages/builder/src/helpers/duplicate.ts +++ b/packages/builder/src/helpers/duplicate.ts @@ -70,10 +70,16 @@ export const duplicateName = (name: string, allNames: string[]) => { * @param getName optional function to extract the name for an item, if not a * flat array of strings */ -export const getSequentialName = ( - items: string[], +export const getSequentialName = ( + items: T[], prefix: string, - { getName = (x: string) => x, numberFirstItem = false } = {} + { + getName, + numberFirstItem, + }: { + getName: (item: T) => string + numberFirstItem?: boolean + } ) => { if (!prefix?.length || !getName) { return null diff --git a/packages/builder/src/stores/builder/rowActions.ts b/packages/builder/src/stores/builder/rowActions.ts index 9576eccd1b..2b3077926e 100644 --- a/packages/builder/src/stores/builder/rowActions.ts +++ b/packages/builder/src/stores/builder/rowActions.ts @@ -62,7 +62,7 @@ export class RowActionStore extends BudiStore { const existingRowActions = get(this)[tableId] || [] name = getSequentialName(existingRowActions, "New row action ", { getName: x => x.name, - }) + })! } if (!name) {