diff --git a/src/components/VocabItemList.vue b/src/components/VocabItemList.vue index 49c4e2a..107678b 100644 --- a/src/components/VocabItemList.vue +++ b/src/components/VocabItemList.vue @@ -3,10 +3,10 @@ import { reactive, watch, ref } from "vue"; import { RouterLink } from "vue-router"; import ItemListSortButton from "@/components/ItemListSortButton.vue"; -import type { ListItem, listingTableColumn } from "@/types"; +import type { VocabListItem, listingTableColumn } from "@/types"; const props = defineProps<{ - items: ListItem[]; + items: VocabListItem[]; childName?: string; childLink?: string; }>(); @@ -61,19 +61,21 @@ watch(sortState, () => { for (const validKey of validKeys) { if (sortState[validKey] === true) { - rows.value = props.items.sort((a: ListItem, b: ListItem) => { + rows.value = props.items.sort((a: VocabListItem, b: VocabListItem) => { const listItemKey = keyToListItem[validKey]; if (a.hasOwnProperty(listItemKey)) { - return a[listItemKey].localeCompare(b[listItemKey]); + return (a[listItemKey] as string).localeCompare(b[listItemKey] as string); } + return 0; }) } else if (sortState[validKey] === false) { - rows.value = props.items.sort((a: ListItem, b: ListItem) => { + rows.value = props.items.sort((a: VocabListItem, b: VocabListItem) => { const listItemKey = keyToListItem[validKey]; if (b.hasOwnProperty(listItemKey)) { - return b[listItemKey].localeCompare(a[listItemKey]); + return (b[listItemKey] as string).localeCompare(a[listItemKey] as string); } + return 0; }) } } diff --git a/src/types.ts b/src/types.ts index 7cbdb5e..b0aee83 100644 --- a/src/types.ts +++ b/src/types.ts @@ -101,6 +101,7 @@ export interface VocabListItem { type?: string; status?: string; derivationMode?: string; + [key: string]: string | undefined; }; export interface AnnotatedPredicate {