Fix types

This commit is contained in:
Adria Navarro 2025-01-14 11:14:30 +01:00
parent 41c8ab976f
commit 8624997f4c
2 changed files with 10 additions and 4 deletions

View File

@ -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 * @param getName optional function to extract the name for an item, if not a
* flat array of strings * flat array of strings
*/ */
export const getSequentialName = ( export const getSequentialName = <T extends string | object>(
items: string[], items: T[],
prefix: string, prefix: string,
{ getName = (x: string) => x, numberFirstItem = false } = {} {
getName,
numberFirstItem,
}: {
getName: (item: T) => string
numberFirstItem?: boolean
}
) => { ) => {
if (!prefix?.length || !getName) { if (!prefix?.length || !getName) {
return null return null

View File

@ -62,7 +62,7 @@ export class RowActionStore extends BudiStore<RowActionState> {
const existingRowActions = get(this)[tableId] || [] const existingRowActions = get(this)[tableId] || []
name = getSequentialName(existingRowActions, "New row action ", { name = getSequentialName(existingRowActions, "New row action ", {
getName: x => x.name, getName: x => x.name,
}) })!
} }
if (!name) { if (!name) {