Fix types
This commit is contained in:
parent
41c8ab976f
commit
8624997f4c
|
@ -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 = <T extends string | object>(
|
||||
items: T[],
|
||||
prefix: string,
|
||||
{ getName = (x: string) => x, numberFirstItem = false } = {}
|
||||
{
|
||||
getName,
|
||||
numberFirstItem,
|
||||
}: {
|
||||
getName: (item: T) => string
|
||||
numberFirstItem?: boolean
|
||||
}
|
||||
) => {
|
||||
if (!prefix?.length || !getName) {
|
||||
return null
|
||||
|
|
|
@ -62,7 +62,7 @@ export class RowActionStore extends BudiStore<RowActionState> {
|
|||
const existingRowActions = get(this)[tableId] || []
|
||||
name = getSequentialName(existingRowActions, "New row action ", {
|
||||
getName: x => x.name,
|
||||
})
|
||||
})!
|
||||
}
|
||||
|
||||
if (!name) {
|
||||
|
|
Loading…
Reference in New Issue