fix: resolve TypeScript build errors from any→unknown migration

- Editor.tsx: use targeted eslint-disable for BlockNote block arrays
  (PartialBlock generic type is extremely complex to reference)
- Editor.tsx: cast through unknown for tryParseMarkdownToBlocks result
  which may be sync or async
- useMcpBridge.ts: cast Promise resolve to (value: unknown) => void
- mock-tauri.ts: cast args.path to string for encodeURIComponent

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
lucaronin
2026-02-22 14:10:42 +01:00
parent 7696a37763
commit 728a111f14
3 changed files with 15 additions and 10 deletions

View File

@@ -238,7 +238,8 @@ export const Editor = memo(function Editor({
},
})
// Cache parsed blocks per tab path for instant switching
const tabCacheRef = useRef<Map<string, unknown[]>>(new Map())
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- BlockNote block arrays
const tabCacheRef = useRef<Map<string, any[]>>(new Map())
const prevActivePathRef = useRef<string | null>(null)
const editorMountedRef = useRef(false)
const pendingSwapRef = useRef<(() => void) | null>(null)
@@ -281,7 +282,8 @@ export const Editor = memo(function Editor({
const tab = tabs.find(t => t.entry.path === activeTabPath)
if (!tab) return
const applyBlocks = (blocks: unknown[]) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- BlockNote's PartialBlock generic is extremely complex
const applyBlocks = (blocks: any[]) => {
try {
const current = editor.document
if (current.length > 0 && blocks.length > 0) {
@@ -317,7 +319,8 @@ export const Editor = memo(function Editor({
try {
const result = editor.tryParseMarkdownToBlocks(preprocessed)
const handleBlocks = (blocks: unknown[]) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- BlockNote block arrays
const handleBlocks = (blocks: any[]) => {
if (prevActivePathRef.current !== targetPath) return
const withWikilinks = injectWikilinks(blocks)
// Only cache non-empty results to avoid poisoning the cache
@@ -326,13 +329,15 @@ export const Editor = memo(function Editor({
}
applyBlocks(withWikilinks)
}
if (result && typeof (result as Promise<unknown[]>).then === 'function') {
(result as Promise<unknown[]>).then(handleBlocks).catch((err) => {
/* eslint-disable @typescript-eslint/no-explicit-any -- tryParseMarkdownToBlocks returns sync or async BlockNote blocks */
if (result && typeof (result as any).then === 'function') {
(result as unknown as Promise<any[]>).then(handleBlocks).catch((err: unknown) => {
console.error('Async markdown parse failed:', err)
})
} else {
handleBlocks(result as unknown[])
handleBlocks(result as any[])
}
/* eslint-enable @typescript-eslint/no-explicit-any */
} catch (err) {
console.error('Failed to parse/swap editor content:', err)
}

View File

@@ -73,7 +73,7 @@ export function useMcpBridge(wsUrl = DEFAULT_WS_URL) {
const id = `mcp-${++idCounterRef.current}`
return new Promise((resolve, reject) => {
pendingRef.current.set(id, { resolve, reject })
pendingRef.current.set(id, { resolve: resolve as (value: unknown) => void, reject })
ws.send(JSON.stringify({ id, tool, args }))
// Timeout after 30 seconds

View File

@@ -1749,18 +1749,18 @@ export async function mockInvoke<T>(cmd: string, args?: Record<string, unknown>)
if (apiAvailable) {
try {
if (cmd === 'list_vault' && args?.path) {
const res = await fetch(`/api/vault/list?path=${encodeURIComponent(args.path)}`)
const res = await fetch(`/api/vault/list?path=${encodeURIComponent(args.path as string)}`)
if (res.ok) return (await res.json()) as T
}
if (cmd === 'get_note_content' && args?.path) {
const res = await fetch(`/api/vault/content?path=${encodeURIComponent(args.path)}`)
const res = await fetch(`/api/vault/content?path=${encodeURIComponent(args.path as string)}`)
if (res.ok) {
const { content } = await res.json()
return content as T
}
}
if (cmd === 'get_all_content' && args?.path) {
const res = await fetch(`/api/vault/all-content?path=${encodeURIComponent(args.path)}`)
const res = await fetch(`/api/vault/all-content?path=${encodeURIComponent(args.path as string)}`)
if (res.ok) return (await res.json()) as T
}
} catch (err) {