From d558b3e29c6649bae2762c7412544d5d82b382bf Mon Sep 17 00:00:00 2001 From: Benjamin Canac Date: Thu, 22 Aug 2024 14:29:58 +0200 Subject: [PATCH] fix(CommandPalette): ts errors --- src/runtime/components/CommandPalette.vue | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/runtime/components/CommandPalette.vue b/src/runtime/components/CommandPalette.vue index 4a82dfbe..1285f86b 100644 --- a/src/runtime/components/CommandPalette.vue +++ b/src/runtime/components/CommandPalette.vue @@ -31,6 +31,7 @@ export interface CommandPaletteGroup { label?: string slot?: string items?: T[] + /** Filter group items based on the search term. */ filter?: (searchTerm: string, items: T[]) => T[] /** The icon displayed when an item is highlighted. */ highlightedIcon?: string @@ -142,14 +143,14 @@ const items = computed(() => props.groups?.filter((group) => { return true }).flatMap(group => group.items?.map(item => ({ ...item, group: group.id })) || []) || []) -const { results: fuseResults } = useFuse(searchTerm, items, fuse) +const { results: fuseResults } = useFuse(searchTerm, items, fuse) const groups = computed(() => { if (!fuseResults.value?.length) { return [] } - const groupsById: Record['matches'] })[]> = fuseResults.value.reduce((acc, result) => { + const groupsById = fuseResults.value.reduce((acc, result) => { const { item, matches } = result if (!item.group) { return acc @@ -159,7 +160,7 @@ const groups = computed(() => { acc[item.group].push({ ...item, matches }) return acc - }, {}) + }, {} as Record['matches'] })[]>) return Object.entries(groupsById).map(([id, items]) => { const group = props.groups?.find(group => group.id === id)