Skip to content

Build your personal knowledge base with Trilium Notes

refactor(types): better type definitions

Elian Doran6f2a0f9ee1b1
diff --git a/src/public/app/test/easy-froca.ts b/src/public/app/test/easy-froca.ts
index 99ac13f1c9..7e214579c7 100644
--- a/src/public/app/test/easy-froca.ts
+++ b/src/public/app/test/easy-froca.ts
@@ -3,9 +3,11 @@ import FNote from "../entities/fnote.js";
import froca from "../services/froca.js";
import FAttribute from "../entities/fattribute.js";
-interface NoteDefinition {
+type AttributeDefinitions = { [key in `#${string}`]: string; }
+
+interface NoteDefinition extends AttributeDefinitions {
+ id?: string | undefined;
title: string;
- [key: string]: string;
}
/**
@@ -27,9 +29,8 @@ export function buildNotes(notes: NoteDefinition[]) {
const ids = [];
for (const noteDef of notes) {
- const fakeNoteId = utils.randomString(6);
const note = new FNote(froca, {
- noteId: fakeNoteId,
+ noteId: noteDef.id ?? utils.randomString(12),
title: noteDef.title,
type: "text",
mime: "text/html",
diff --git a/src/public/app/widgets/view_widgets/calendar_view.spec.ts b/src/public/app/widgets/view_widgets/calendar_view.spec.ts
index b191d486c3..e5b536a62d 100644
--- a/src/public/app/widgets/view_widgets/calendar_view.spec.ts
+++ b/src/public/app/widgets/view_widgets/calendar_view.spec.ts
@@ -18,7 +18,7 @@ describe("Building events", () => {
it("ignores notes with only end date", async () => {
const noteIds = buildNotes([
{ title: "Note 1", "#endDate": "2025-05-05" },
- { title: "Note 2", "#endDateDate": "2025-05-07" },
+ { title: "Note 2", "#endDateDate": "2025-05-07" }
]);
const events = await CalendarView.buildEvents(noteIds);