fix: resolve TypeScript build errors in refactored code and test mocks

- Remove unused cn import from NoteList.tsx
- Fix SidebarSelection type narrowing in NoteList entity view
- Fix SortableSection onToggle type in Sidebar Omit type
- Fix TypeRow isA prop to accept null
- Align useEntryActions handleUpdateFrontmatter value type
- Add missing trashed/trashedAt/order to test mock VaultEntry objects

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
lucaronin
2026-02-22 11:00:07 +01:00
parent 65d1c753ef
commit 5bbd1469e2
8 changed files with 16 additions and 9 deletions

View File

@@ -24,6 +24,7 @@ const baseEntry: VaultEntry = {
relationships: {},
icon: null,
color: null,
order: null,
}
const archivedEntry: VaultEntry = {

View File

@@ -139,7 +139,7 @@ function AddPropertyForm({ onAdd, onCancel }: { onAdd: (key: string, value: stri
)
}
function TypeRow({ isA, onNavigate }: { isA?: string; onNavigate?: (target: string) => void }) {
function TypeRow({ isA, onNavigate }: { isA?: string | null; onNavigate?: (target: string) => void }) {
if (!isA) return null
return (
<div className="flex items-center justify-between">

View File

@@ -276,6 +276,8 @@ describe('getSortComparator', () => {
owner: null,
cadence: null,
archived: false,
trashed: false,
trashedAt: null,
modifiedAt: null,
createdAt: null,
fileSize: 100,
@@ -352,6 +354,8 @@ describe('NoteList sort controls', () => {
owner: null,
cadence: null,
archived: false,
trashed: false,
trashedAt: null,
modifiedAt: null,
createdAt: null,
fileSize: 100,
@@ -486,6 +490,7 @@ const trashedEntry: VaultEntry = {
relationships: {},
icon: null,
color: null,
order: null,
}
const expiredTrashedEntry: VaultEntry = {
@@ -509,6 +514,7 @@ const expiredTrashedEntry: VaultEntry = {
relationships: {},
icon: null,
color: null,
order: null,
}
const entriesWithTrashed = [...mockEntries, trashedEntry, expiredTrashedEntry]

View File

@@ -1,6 +1,5 @@
import { useState, useMemo, useCallback, memo } from 'react'
import type { VaultEntry, SidebarSelection, ModifiedFile } from '../types'
import { cn } from '@/lib/utils'
import { Input } from '@/components/ui/input'
import {
MagnifyingGlass, Plus, CaretDown, CaretRight, Warning,
@@ -254,7 +253,7 @@ function NoteListInner({ entries, selection, selectedNote, allContent, modifiedF
)}
<div className="flex-1 overflow-hidden" style={{ minHeight: 0 }}>
{isEntityView ? (
{isEntityView && selection.kind === 'entity' ? (
<EntityView entity={selection.entry} groups={searchedGroups} query={query} collapsedGroups={collapsedGroups} sortPrefs={sortPrefs} onToggleGroup={toggleGroup} onSortChange={handleSortChange} renderItem={renderItem} typeEntryMap={typeEntryMap} onSelectNote={onSelectNote} />
) : (
<ListView typeDocument={typeDocument} isTrashView={isTrashView} expiredTrashCount={expiredTrashCount} searched={searched} query={query} renderItem={renderItem} typeEntryMap={typeEntryMap} onSelectNote={onSelectNote} />

View File

@@ -571,19 +571,19 @@ describe('Sidebar', () => {
{
path: '/vault/type/project.md', filename: 'project.md', title: 'Project', isA: 'Type',
aliases: [], belongsTo: [], relatedTo: [], status: null, owner: null, cadence: null,
archived: false, modifiedAt: 1700000000, createdAt: null, fileSize: 200, snippet: '',
archived: false, trashed: false, trashedAt: null, modifiedAt: 1700000000, createdAt: null, fileSize: 200, snippet: '',
relationships: {}, icon: null, color: null, order: 5,
},
{
path: '/vault/type/topic.md', filename: 'topic.md', title: 'Topic', isA: 'Type',
aliases: [], belongsTo: [], relatedTo: [], status: null, owner: null, cadence: null,
archived: false, modifiedAt: 1700000000, createdAt: null, fileSize: 200, snippet: '',
archived: false, trashed: false, trashedAt: null, modifiedAt: 1700000000, createdAt: null, fileSize: 200, snippet: '',
relationships: {}, icon: null, color: null, order: 0,
},
{
path: '/vault/type/person.md', filename: 'person.md', title: 'Person', isA: 'Type',
aliases: [], belongsTo: [], relatedTo: [], status: null, owner: null, cadence: null,
archived: false, modifiedAt: 1700000000, createdAt: null, fileSize: 200, snippet: '',
archived: false, trashed: false, trashedAt: null, modifiedAt: 1700000000, createdAt: null, fileSize: 200, snippet: '',
relationships: {}, icon: null, color: null, order: 1,
},
]

View File

@@ -133,7 +133,7 @@ function buildCustomizeArgs(typeEntry: VaultEntry, prop: 'icon' | 'color', value
function SortableSection({ group, sectionProps }: {
group: SectionGroup
sectionProps: Omit<SectionContentProps, 'group' | 'items' | 'isCollapsed' | 'dragHandleProps'>
sectionProps: Omit<SectionContentProps, 'group' | 'items' | 'isCollapsed' | 'dragHandleProps' | 'onToggle'>
& { entries: VaultEntry[]; collapsed: Record<string, boolean>; onToggle: (type: string) => void }
}) {
const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ id: group.type })

View File

@@ -8,8 +8,9 @@ function makeEntry(path: string, title: string): VaultEntry {
path, filename: `${title}.md`, title, isA: 'Note',
aliases: [], belongsTo: [], relatedTo: [],
status: null, owner: null, cadence: null, archived: false,
trashed: false, trashedAt: null,
modifiedAt: null, createdAt: null, fileSize: 0,
snippet: '', relationships: {}, icon: null, color: null,
snippet: '', relationships: {}, icon: null, color: null, order: null,
}
}

View File

@@ -4,7 +4,7 @@ import type { VaultEntry } from '../types'
interface EntryActionsConfig {
entries: VaultEntry[]
updateEntry: (path: string, updates: Partial<VaultEntry>) => void
handleUpdateFrontmatter: (path: string, key: string, value: unknown) => Promise<void>
handleUpdateFrontmatter: (path: string, key: string, value: string | number | boolean | string[]) => Promise<void>
handleDeleteProperty: (path: string, key: string) => Promise<void>
setToastMessage: (msg: string | null) => void
}