Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(client): clean up typecheck errors
Elian Doran5b03c1ec8601
diff --git a/apps/client/src/services/content_renderer.spec.ts b/apps/client/src/services/content_renderer.spec.tsindex 947c8ca030..646083ceb8 100644--- a/apps/client/src/services/content_renderer.spec.ts+++ b/apps/client/src/services/content_renderer.spec.ts@@ -69,10 +69,10 @@ vi.mock("mermaid", () => ({const pdfViewerComponent = vi.fn(() => null);vi.mock("../widgets/type_widgets/file/PdfViewer", () => ({ default: pdfViewerComponent }));-const webViewComponent = vi.fn(() => h("span", { class: "mock-webview-marker" }));+const webViewComponent = vi.fn((_props: any) => h("span", { class: "mock-webview-marker" }));vi.mock("../widgets/type_widgets/WebView", () => ({ default: webViewComponent }));-const embeddedNoteListComponent = vi.fn(() => null);+const embeddedNoteListComponent = vi.fn((_props: any) => null);vi.mock("../widgets/collections/NoteList", () => ({ EmbeddedNoteList: embeddedNoteListComponent }));// `addHook` is a no-op here: sanitize_content.ts registers a DOMPurify hook atdiff --git a/apps/client/src/widgets/collections/NoteList.spec.tsx b/apps/client/src/widgets/collections/NoteList.spec.tsxindex 557b6f74de..3d8a041b91 100644--- a/apps/client/src/widgets/collections/NoteList.spec.tsx+++ b/apps/client/src/widgets/collections/NoteList.spec.tsx@@ -80,11 +80,11 @@ describe("useNoteIds refresh race", () => {container = document.createElement("div");document.body.appendChild(container);- return { note, pending, parent };+ return { note, pending, parent, container };}it("commits the newest refresh even when an older one resolves last", async () => {- const { note, pending, parent } = setup();+ const { note, pending, parent, container } = setup();// Mount issues the first refresh (reflecting the pre-clone child set).await act(async () => {@@ -120,7 +120,7 @@ describe("useNoteIds refresh race", () => {});it("applies a single refresh's result normally", async () => {- const { note, pending, parent } = setup();+ const { note, pending, parent, container } = setup();await act(async () => {render(@@ -150,15 +150,16 @@ describe("useNoteIds refresh race", () => {note.getChildNoteIdsWithArchiveFiltering = vi.fn(async () => liveChildren);const parent = new Component();- container = document.createElement("div");- document.body.appendChild(container);+ const mountPoint = document.createElement("div");+ container = mountPoint;+ document.body.appendChild(mountPoint);await act(async () => {render(<ParentComponent.Provider value={parent}><Harness note={note} /></ParentComponent.Provider>,- container+ mountPoint);});// Drain the mount refresh's async chain (effect → getNoteIds → setNoteIds).diff --git a/apps/client/src/widgets/type_widgets/canvas/useCanvasNoteDrop.ts b/apps/client/src/widgets/type_widgets/canvas/useCanvasNoteDrop.tsindex 904d126706..d1cefb61e7 100644--- a/apps/client/src/widgets/type_widgets/canvas/useCanvasNoteDrop.ts+++ b/apps/client/src/widgets/type_widgets/canvas/useCanvasNoteDrop.ts@@ -1,4 +1,5 @@import { restoreElements, viewportCoordsToSceneCoords } from "@excalidraw/excalidraw";+import { ExcalidrawEmbeddableElement } from "@excalidraw/excalidraw/element/types";import { ExcalidrawImperativeAPI } from "@excalidraw/excalidraw/types";import { RefObject } from "preact";import { JSX } from "preact";@@ -48,7 +49,8 @@ export default function useCanvasNoteDrop(apiRef: RefObject<ExcalidrawImperative// `restoreElements` (rather than `convertToExcalidrawElements`) normalizes these partial// elements: Excalidraw's element factory is skipped for embeddables, so a bare skeleton// would omit `backgroundColor`/`strokeColor`/`seed`/etc. and crash hit-testing. restore- // fills every default (and generates fresh ids).+ // fills every default (and generates fresh ids). We assert to the concrete embeddable type+ // (a superset of these literals); an embeddable array is a valid restoreElements input.const partialElements = noteIds.map((noteId, i) => ({type: "embeddable",x: x + i * STACK_OFFSET,@@ -56,7 +58,7 @@ export default function useCanvasNoteDrop(apiRef: RefObject<ExcalidrawImperativewidth: EMBEDDABLE_WIDTH,height: EMBEDDABLE_HEIGHT,link: `root/${noteId}`- })) as Parameters<typeof restoreElements>[0];+ })) as ExcalidrawEmbeddableElement[];const newElements = restoreElements(partialElements, null);api.updateScene({ elements: [...api.getSceneElements(), ...newElements] });