From 26c1cbeff164325f085a37fc984e1e0b8daa92b7 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Wed, 28 May 2025 20:42:21 +0300 Subject: [PATCH] chore(client): fix most type errors --- apps/client/src/components/app_context.ts | 3 ++- apps/client/src/components/touch_bar.ts | 2 +- apps/client/src/entities/fnote.ts | 2 +- apps/client/src/services/clipboard.ts | 2 +- apps/client/src/services/froca_updater.ts | 2 +- apps/client/src/services/link.ts | 6 ++--- .../promoted_attribute_definition_parser.ts | 2 +- apps/client/src/services/tree.ts | 8 +++---- apps/client/src/services/utils.ts | 6 ++--- apps/client/src/test/easy-froca.ts | 2 +- .../attribute_widgets/attribute_detail.ts | 6 ++--- .../widgets/containers/launcher_container.ts | 2 +- .../containers/split_note_container.ts | 2 +- apps/client/src/widgets/find_in_text.ts | 12 +--------- apps/client/src/widgets/highlights_list.ts | 7 +++--- apps/client/src/widgets/note_tree.ts | 10 ++++---- .../src/widgets/ribbon_widgets/note_paths.ts | 8 +++---- .../ribbon_widgets/promoted_attributes.ts | 2 +- apps/client/src/widgets/tab_row.ts | 10 ++++---- apps/client/src/widgets/toc.ts | 12 ++++++---- .../abstract_svg_split_type_widget.ts | 4 ++-- .../widgets/type_widgets/ckeditor/config.ts | 2 +- .../src/widgets/type_widgets/editable_text.ts | 2 +- .../src/widgets/type_widgets/mind_map.ts | 6 ++--- .../options/ai_settings/ai_settings_widget.ts | 10 ++++---- .../src/widgets/view_widgets/calendar_view.ts | 24 ++++++++++--------- 26 files changed, 75 insertions(+), 79 deletions(-) diff --git a/apps/client/src/components/app_context.ts b/apps/client/src/components/app_context.ts index b64678011..f7a5dfb1e 100644 --- a/apps/client/src/components/app_context.ts +++ b/apps/client/src/components/app_context.ts @@ -27,6 +27,7 @@ import type EditableTextTypeWidget from "../widgets/type_widgets/editable_text.j import type { NativeImage, TouchBar } from "electron"; import TouchBarComponent from "./touch_bar.js"; import type { CKTextEditor } from "@triliumnext/ckeditor5"; +import type CodeMirror from "@triliumnext/codemirror"; interface Layout { getRootWidget: (appContext: AppContext) => RootWidget; @@ -191,7 +192,7 @@ export type CommandMappings = { ExecuteCommandData & { callback?: GetTextEditorCallback; }; - executeWithCodeEditor: CommandData & ExecuteCommandData; + executeWithCodeEditor: CommandData & ExecuteCommandData; /** * Called upon when attempting to retrieve the content element of a {@link NoteContext}. * Generally should not be invoked manually, as it is used by {@link NoteContext.getContentElement}. diff --git a/apps/client/src/components/touch_bar.ts b/apps/client/src/components/touch_bar.ts index 4afe65151..7bf10d7f1 100644 --- a/apps/client/src/components/touch_bar.ts +++ b/apps/client/src/components/touch_bar.ts @@ -54,7 +54,7 @@ export default class TouchBarComponent extends Component { #refreshTouchBar() { const { TouchBar } = this.remote; const parentComponent = this.lastFocusedComponent; - let touchBar = null; + let touchBar: Electron.CrossProcessExports.TouchBar | null = null; if (this.$activeModal?.length) { touchBar = this.#buildModalTouchBar(); diff --git a/apps/client/src/entities/fnote.ts b/apps/client/src/entities/fnote.ts index e968dcae9..9e215821d 100644 --- a/apps/client/src/entities/fnote.ts +++ b/apps/client/src/entities/fnote.ts @@ -789,7 +789,7 @@ class FNote { */ async getRelationTargets(name: string) { const relations = this.getRelations(name); - const targets = []; + const targets: (FNote | null)[] = []; for (const relation of relations) { targets.push(await this.froca.getNote(relation.value)); diff --git a/apps/client/src/services/clipboard.ts b/apps/client/src/services/clipboard.ts index 2da2d1cf3..002309586 100644 --- a/apps/client/src/services/clipboard.ts +++ b/apps/client/src/services/clipboard.ts @@ -80,7 +80,7 @@ async function copy(branchIds: string[]) { if (utils.isElectron()) { // https://github.com/zadam/trilium/issues/2401 const { clipboard } = require("electron"); - const links = []; + const links: string[] = []; for (const branch of froca.getBranches(clipboardBranchIds)) { const $link = await linkService.createLink(`${branch.parentNoteId}/${branch.noteId}`, { referenceLink: true }); diff --git a/apps/client/src/services/froca_updater.ts b/apps/client/src/services/froca_updater.ts index 37f9d2814..1f8eaa541 100644 --- a/apps/client/src/services/froca_updater.ts +++ b/apps/client/src/services/froca_updater.ts @@ -50,7 +50,7 @@ async function processEntityChanges(entityChanges: EntityChange[]) { // To this we count: standard parent-child relationships and template/inherit relations (attribute inheritance follows them). // Here we watch for changes which might violate this principle - e.g., an introduction of a new "inherit" relation might // mean we need to load the target of the relation (and then perhaps transitively the whole note path of this target). - const missingNoteIds = []; + const missingNoteIds: string[] = []; for (const { entityName, entity } of entityChanges) { if (!entity) { diff --git a/apps/client/src/services/link.ts b/apps/client/src/services/link.ts index 3dac7688f..0425652f6 100644 --- a/apps/client/src/services/link.ts +++ b/apps/client/src/services/link.ts @@ -215,9 +215,9 @@ export function parseNavigationStateFromUrl(url: string | undefined) { const viewScope: ViewScope = { viewMode: "default" }; - let ntxId = null; - let hoistedNoteId = null; - let searchString = null; + let ntxId: string | null = null; + let hoistedNoteId: string | null = null; + let searchString: string | null = null; if (paramString) { for (const pair of paramString.split("&")) { diff --git a/apps/client/src/services/promoted_attribute_definition_parser.ts b/apps/client/src/services/promoted_attribute_definition_parser.ts index e40c24bbc..f46040e2a 100644 --- a/apps/client/src/services/promoted_attribute_definition_parser.ts +++ b/apps/client/src/services/promoted_attribute_definition_parser.ts @@ -1,7 +1,7 @@ type LabelType = "text" | "number" | "boolean" | "date" | "datetime" | "time" | "url"; type Multiplicity = "single" | "multi"; -interface DefinitionObject { +export interface DefinitionObject { isPromoted?: boolean; labelType?: LabelType; multiplicity?: Multiplicity; diff --git a/apps/client/src/services/tree.ts b/apps/client/src/services/tree.ts index 485447214..c508654f5 100644 --- a/apps/client/src/services/tree.ts +++ b/apps/client/src/services/tree.ts @@ -34,8 +34,8 @@ async function resolveNotePathToSegments(notePath: string, hoistedNoteId = "root path.push("root"); } - const effectivePathSegments = []; - let childNoteId = null; + const effectivePathSegments: string[] = []; + let childNoteId: string | null = null; let i = 0; while (true) { @@ -197,7 +197,7 @@ function getNotePath(node: Fancytree.FancytreeNode) { return ""; } - const path = []; + const path: string[] = []; while (node) { if (node.data.noteId) { @@ -236,7 +236,7 @@ async function getNoteTitle(noteId: string, parentNoteId: string | null = null) } async function getNotePathTitleComponents(notePath: string) { - const titleComponents = []; + const titleComponents: string[] = []; if (notePath.startsWith("root/")) { notePath = notePath.substr(5); diff --git a/apps/client/src/services/utils.ts b/apps/client/src/services/utils.ts index a52b7443a..ab6e45847 100644 --- a/apps/client/src/services/utils.ts +++ b/apps/client/src/services/utils.ts @@ -51,7 +51,7 @@ function getMonthsInDateRange(startDate: string, endDate: string) { const end = endDate.split("-"); const startYear = parseInt(start[0]); const endYear = parseInt(end[0]); - const dates = []; + const dates: string[] = []; for (let i = startYear; i <= endYear; i++) { const endMonth = i != endYear ? 11 : parseInt(end[1]) - 1; @@ -84,7 +84,7 @@ function formatTimeInterval(ms: number) { const hours = Math.floor(minutes / 60); const days = Math.floor(hours / 24); const plural = (count: number, name: string) => `${count} ${name}${count > 1 ? "s" : ""}`; - const segments = []; + const segments: string[] = []; if (days > 0) { segments.push(plural(days, "day")); @@ -149,7 +149,7 @@ function isMac() { export const hasTouchBar = (isMac() && isElectron()); -function isCtrlKey(evt: KeyboardEvent | MouseEvent | JQuery.ClickEvent | JQuery.ContextMenuEvent | JQuery.TriggeredEvent | React.PointerEvent) { +function isCtrlKey(evt: KeyboardEvent | MouseEvent | JQuery.ClickEvent | JQuery.ContextMenuEvent | JQuery.TriggeredEvent | React.PointerEvent | JQueryEventObject) { return (!isMac() && evt.ctrlKey) || (isMac() && evt.metaKey); } diff --git a/apps/client/src/test/easy-froca.ts b/apps/client/src/test/easy-froca.ts index 0ccb768fd..045819ab5 100644 --- a/apps/client/src/test/easy-froca.ts +++ b/apps/client/src/test/easy-froca.ts @@ -28,7 +28,7 @@ interface NoteDefinition extends AttributeDefinitions, RelationDefinitions { * ]); */ export function buildNotes(notes: NoteDefinition[]) { - const ids = []; + const ids: string[] = []; for (const noteDef of notes) { ids.push(buildNote(noteDef).noteId); diff --git a/apps/client/src/widgets/attribute_widgets/attribute_detail.ts b/apps/client/src/widgets/attribute_widgets/attribute_detail.ts index 94d2bfa29..08bb764fc 100644 --- a/apps/client/src/widgets/attribute_widgets/attribute_detail.ts +++ b/apps/client/src/widgets/attribute_widgets/attribute_detail.ts @@ -718,7 +718,7 @@ export default class AttributeDetailWidget extends NoteContextAwareWidget { } buildDefinitionValue() { - const props = []; + const props: string[] = []; if (this.$inputPromoted.is(":checked")) { props.push("promoted"); @@ -728,10 +728,10 @@ export default class AttributeDetailWidget extends NoteContextAwareWidget { } } - props.push(this.$inputMultiplicity.val()); + props.push(this.$inputMultiplicity.val() as string); if (this.attrType === "label-definition") { - props.push(this.$inputLabelType.val()); + props.push(this.$inputLabelType.val() as string); if (this.$inputLabelType.val() === "number" && this.$inputNumberPrecision.val() !== "") { props.push(`precision=${this.$inputNumberPrecision.val()}`); diff --git a/apps/client/src/widgets/containers/launcher_container.ts b/apps/client/src/widgets/containers/launcher_container.ts index 5a814d1fa..f684d4e6b 100644 --- a/apps/client/src/widgets/containers/launcher_container.ts +++ b/apps/client/src/widgets/containers/launcher_container.ts @@ -29,7 +29,7 @@ export default class LauncherContainer extends FlexContainer { return; } - const newChildren = []; + const newChildren: LauncherWidget[] = []; for (const launcherNote of await visibleLaunchersRoot.getChildNotes()) { try { diff --git a/apps/client/src/widgets/containers/split_note_container.ts b/apps/client/src/widgets/containers/split_note_container.ts index 9bd5c04b5..99165437c 100644 --- a/apps/client/src/widgets/containers/split_note_container.ts +++ b/apps/client/src/widgets/containers/split_note_container.ts @@ -217,7 +217,7 @@ export default class SplitNoteContainer extends FlexContainer { } refreshNotShown(data: NoteSwitchedContext | EventData<"activeContextChanged">) { - const promises = []; + const promises: (Promise | null | undefined)[] = []; for (const subContext of data.noteContext.getMainContext().getSubContexts()) { if (!subContext.ntxId) { diff --git a/apps/client/src/widgets/find_in_text.ts b/apps/client/src/widgets/find_in_text.ts index 959fcdf34..e97a7a8df 100644 --- a/apps/client/src/widgets/find_in_text.ts +++ b/apps/client/src/widgets/find_in_text.ts @@ -2,16 +2,6 @@ import type { FindAndReplaceState, FindCommandResult } from "@triliumnext/ckedit import type { FindResult } from "./find.js"; import type FindWidget from "./find.js"; -// TODO: Deduplicate. -interface Match { - className: string; - clear(): void; - find(): { - from: number; - to: number; - }; -} - export default class FindInText { private parent: FindWidget; @@ -35,7 +25,7 @@ export default class FindInText { } const model = textEditor.model; - let findResult = null; + let findResult: FindCommandResult | null = null; let totalFound = 0; let currentFound = -1; diff --git a/apps/client/src/widgets/highlights_list.ts b/apps/client/src/widgets/highlights_list.ts index f37b82955..38a736f7e 100644 --- a/apps/client/src/widgets/highlights_list.ts +++ b/apps/client/src/widgets/highlights_list.ts @@ -243,7 +243,7 @@ export default class HighlightsListWidget extends RightPanelWidget { // Used to determine if a string is only a formula const onlyMathRegex = /^\\\([^\)]*?\)<\/span>(?:\\\([^\)]*?\)<\/span>)*$/; - for (let match = null, hltIndex = 0; (match = combinedRegex.exec(content)) !== null; hltIndex++) { + for (let match: RegExpMatchArray | null = null, hltIndex = 0; (match = combinedRegex.exec(content)) !== null; hltIndex++) { const subHtml = match[0]; const startIndex = match.index; const endIndex = combinedRegex.lastIndex; @@ -324,8 +324,9 @@ export default class HighlightsListWidget extends RightPanelWidget { }); } else { const textEditor = await this.noteContext.getTextEditor(); - if (textEditor) { - targetElement = $(textEditor.editing.view.domRoots.values().next().value) + const el = textEditor?.editing.view.domRoots.values().next().value; + if (el) { + targetElement = $(el) .find(findSubStr) .filter(function () { // When finding span[style*="color"] but not looking for span[style*="background-color"], diff --git a/apps/client/src/widgets/note_tree.ts b/apps/client/src/widgets/note_tree.ts index 825e6d8f8..662562f42 100644 --- a/apps/client/src/widgets/note_tree.ts +++ b/apps/client/src/widgets/note_tree.ts @@ -350,7 +350,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { }, scrollParent: this.$tree, minExpandLevel: 2, // root can't be collapsed - click: (event: MouseEvent | JQuery.ClickEvent | JQuery.MouseDownEvent | React.PointerEvent, data): boolean => { + click: (event, data): boolean => { this.activityDetected(); const targetType = data.targetType; @@ -745,7 +745,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { prepareChildren(parentNote: FNote) { utils.assertArguments(parentNote); - const noteList = []; + const noteList: Node[] = []; const hideArchivedNotes = this.hideArchivedNotes; @@ -839,7 +839,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { getExtraClasses(note: FNote) { utils.assertArguments(note); - const extraClasses = []; + const extraClasses: string[] = []; if (note.isProtected) { extraClasses.push("protected"); @@ -1265,8 +1265,8 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { const allBranchesDeleted = branchRows.every((branchRow) => !!branchRow.isDeleted); // activeNode is supposed to be moved when we find out activeNode is deleted but not all branches are deleted. save it for fixing activeNodePath after all nodes loaded. - let movedActiveNode = null; - let parentsOfAddedNodes = []; + let movedActiveNode: Fancytree.FancytreeNode | null = null; + let parentsOfAddedNodes: Fancytree.FancytreeNode[] = []; for (const branchRow of branchRows) { if (branchRow.noteId) { diff --git a/apps/client/src/widgets/ribbon_widgets/note_paths.ts b/apps/client/src/widgets/ribbon_widgets/note_paths.ts index 131fed2a4..8681bfd21 100644 --- a/apps/client/src/widgets/ribbon_widgets/note_paths.ts +++ b/apps/client/src/widgets/ribbon_widgets/note_paths.ts @@ -85,7 +85,7 @@ export default class NotePathsWidget extends NoteContextAwareWidget { this.$notePathIntro.text(t("note_paths.intro_not_placed")); } - const renderedPaths = []; + const renderedPaths: JQuery[] = []; for (const notePathRecord of sortedNotePaths) { const notePath = notePathRecord.notePath; @@ -100,7 +100,7 @@ export default class NotePathsWidget extends NoteContextAwareWidget { const $pathItem = $("
  • "); const pathSegments: string[] = []; const lastIndex = notePath.length - 1; - + for (let i = 0; i < notePath.length; i++) { const noteId = notePath[i]; pathSegments.push(noteId); @@ -109,13 +109,13 @@ export default class NotePathsWidget extends NoteContextAwareWidget { $noteLink.find("a").addClass("no-tooltip-preview tn-link"); $pathItem.append($noteLink); - + if (i != lastIndex) { $pathItem.append(" / "); } } - const icons = []; + const icons: string[] = []; if (this.notePath === notePath.join("/")) { $pathItem.addClass("path-current"); diff --git a/apps/client/src/widgets/ribbon_widgets/promoted_attributes.ts b/apps/client/src/widgets/ribbon_widgets/promoted_attributes.ts index 861fef657..d94cfdbd1 100644 --- a/apps/client/src/widgets/ribbon_widgets/promoted_attributes.ts +++ b/apps/client/src/widgets/ribbon_widgets/promoted_attributes.ts @@ -122,7 +122,7 @@ export default class PromotedAttributesWidget extends NoteContextAwareWidget { return; } - const $cells = []; + const $cells: JQuery[] = []; for (const definitionAttr of promotedDefAttrs) { const valueType = definitionAttr.name.startsWith("label:") ? "label" : "relation"; diff --git a/apps/client/src/widgets/tab_row.ts b/apps/client/src/widgets/tab_row.ts index c5fb4e582..c846a20a6 100644 --- a/apps/client/src/widgets/tab_row.ts +++ b/apps/client/src/widgets/tab_row.ts @@ -208,7 +208,7 @@ const TAB_ROW_TPL = ` color: var(--active-tab-text-color); box-shadow: inset -1px 0 0 0 var(--main-border-color); } - + .tab-scroll-button-right { color: var(--active-tab-text-color); box-shadow: inset 1px 0 0 0 var(--main-border-color); @@ -279,7 +279,7 @@ const TAB_ROW_TPL = ` width: 100%; height: 100%; } - + .tab-row-widget-scrolling-container { overflow-x: auto; overflow-y: hidden; @@ -287,9 +287,9 @@ const TAB_ROW_TPL = ` } /* Chrome/Safari */ .tab-row-widget-scrolling-container::-webkit-scrollbar { - display: none; + display: none; } - +
    @@ -480,7 +480,7 @@ export default class TabRowWidget extends BasicWidget { const totalTabsWidthUsingTarget = flooredClampedTargetWidth * numberOfTabs + marginWidth; const totalExtraWidthDueToFlooring = tabsContainerWidth - totalTabsWidthUsingTarget; - const widths = []; + const widths: number[] = []; let extraWidthRemaining = totalExtraWidthDueToFlooring; for (let i = 0; i < numberOfTabs; i += 1) { diff --git a/apps/client/src/widgets/toc.ts b/apps/client/src/widgets/toc.ts index c5fda409c..a5db7ff1b 100644 --- a/apps/client/src/widgets/toc.ts +++ b/apps/client/src/widgets/toc.ts @@ -64,7 +64,7 @@ const TPL = /*html*/`
    } .toc > ol { - --toc-depth-level: 1; + --toc-depth-level: 1; } .toc > ol > ol { --toc-depth-level: 2; @@ -84,7 +84,7 @@ const TPL = /*html*/`
    } .toc li { - padding-left: calc((var(--toc-depth-level) - 1) * 20px + 4px); + padding-left: calc((var(--toc-depth-level) - 1) * 20px + 4px); } .toc li .collapse-button { @@ -304,7 +304,7 @@ export default class TocWidget extends RightPanelWidget { const validHeadingKeys = new Set(); // Used to clean up obsolete entries in tocCollapsedHeadings let headingCount = 0; - for (let m = null, headingIndex = 0; (m = headingTagsRegex.exec(html)) !== null; headingIndex++) { + for (let m: RegExpMatchArray | null = null, headingIndex = 0; (m = headingTagsRegex.exec(html)) !== null; headingIndex++) { // // Nest/unnest whatever necessary number of ordered lists // @@ -394,12 +394,14 @@ export default class TocWidget extends RightPanelWidget { const isDocNote = this.note.type === "doc"; const isReadOnly = await this.noteContext.isReadOnly(); - let $container; + let $container: JQuery | null = null; if (isReadOnly || isDocNote) { $container = await this.noteContext.getContentElement(); } else { const textEditor = await this.noteContext.getTextEditor(); - $container = $(textEditor.sourceElement); + if (textEditor?.sourceElement) { + $container = $(textEditor.sourceElement); + } } const headingElement = $container?.find(":header:not(section.include-note :header)")?.[headingIndex]; diff --git a/apps/client/src/widgets/type_widgets/abstract_svg_split_type_widget.ts b/apps/client/src/widgets/type_widgets/abstract_svg_split_type_widget.ts index 24c2c1ae4..45eba8890 100644 --- a/apps/client/src/widgets/type_widgets/abstract_svg_split_type_widget.ts +++ b/apps/client/src/widgets/type_widgets/abstract_svg_split_type_widget.ts @@ -138,8 +138,8 @@ export default abstract class AbstractSvgSplitTypeWidget extends AbstractSplitTy */ async #setupPanZoom(preservePanZoom: boolean) { // Clean up - let pan = null; - let zoom = null; + let pan: SvgPanZoom.Point | null = null; + let zoom: number | null = null; if (preservePanZoom && this.zoomInstance) { // Store pan and zoom for same note, when the user is editing the note. pan = this.zoomInstance.getPan(); diff --git a/apps/client/src/widgets/type_widgets/ckeditor/config.ts b/apps/client/src/widgets/type_widgets/ckeditor/config.ts index 8cd2ba66d..93eea459d 100644 --- a/apps/client/src/widgets/type_widgets/ckeditor/config.ts +++ b/apps/client/src/widgets/type_widgets/ckeditor/config.ts @@ -134,7 +134,7 @@ export function buildToolbarConfig(isClassicToolbar: boolean) { export function buildMobileToolbar() { const classicConfig = buildClassicToolbar(false); - const items = []; + const items: string[] = []; for (const item of classicConfig.toolbar.items) { if (typeof item === "object" && "items" in item) { diff --git a/apps/client/src/widgets/type_widgets/editable_text.ts b/apps/client/src/widgets/type_widgets/editable_text.ts index a50b7a638..ca4ea98b2 100644 --- a/apps/client/src/widgets/type_widgets/editable_text.ts +++ b/apps/client/src/widgets/type_widgets/editable_text.ts @@ -589,7 +589,7 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget { backgroundColor: buildSelectedBackgroundColor(editor.commands.get(command)?.value as boolean) }); - let headingSelectedIndex = undefined; + let headingSelectedIndex: number | undefined = undefined; const headingCommand = editor.commands.get("heading"); const paragraphCommand = editor.commands.get("paragraph"); if (paragraphCommand?.value) { diff --git a/apps/client/src/widgets/type_widgets/mind_map.ts b/apps/client/src/widgets/type_widgets/mind_map.ts index 83d2e0e96..18867bc83 100644 --- a/apps/client/src/widgets/type_widgets/mind_map.ts +++ b/apps/client/src/widgets/type_widgets/mind_map.ts @@ -207,8 +207,8 @@ export default class MindMapWidget extends TypeWidget { await this.#initLibrary(content?.direction); } - this.mind.refresh(content ?? this.MindElixir.new(NEW_TOPIC_NAME)); - this.mind.toCenter(); + this.mind!.refresh(content ?? this.MindElixir.new(NEW_TOPIC_NAME)); + this.mind!.toCenter(); } async #initLibrary(direction?: number) { @@ -259,7 +259,7 @@ export default class MindMapWidget extends TypeWidget { } async renderSvg() { - return await this.mind.exportSvg().text(); + return await this.mind!.exportSvg().text(); } async entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) { diff --git a/apps/client/src/widgets/type_widgets/options/ai_settings/ai_settings_widget.ts b/apps/client/src/widgets/type_widgets/options/ai_settings/ai_settings_widget.ts index 8f76eac4b..da7321d18 100644 --- a/apps/client/src/widgets/type_widgets/options/ai_settings/ai_settings_widget.ts +++ b/apps/client/src/widgets/type_widgets/options/ai_settings/ai_settings_widget.ts @@ -198,7 +198,7 @@ export default class AiSettingsWidget extends OptionsWidget { const providerPrecedence = (this.$widget.find('.ai-provider-precedence').val() as string || '').split(','); // Check for OpenAI configuration if it's in the precedence list - const openaiWarnings = []; + const openaiWarnings: string[] = []; if (providerPrecedence.includes('openai')) { const openaiApiKey = this.$widget.find('.openai-api-key').val(); if (!openaiApiKey) { @@ -207,7 +207,7 @@ export default class AiSettingsWidget extends OptionsWidget { } // Check for Anthropic configuration if it's in the precedence list - const anthropicWarnings = []; + const anthropicWarnings: string[] = []; if (providerPrecedence.includes('anthropic')) { const anthropicApiKey = this.$widget.find('.anthropic-api-key').val(); if (!anthropicApiKey) { @@ -216,7 +216,7 @@ export default class AiSettingsWidget extends OptionsWidget { } // Check for Voyage configuration if it's in the precedence list - const voyageWarnings = []; + const voyageWarnings: string[] = []; if (providerPrecedence.includes('voyage')) { const voyageApiKey = this.$widget.find('.voyage-api-key').val(); if (!voyageApiKey) { @@ -225,7 +225,7 @@ export default class AiSettingsWidget extends OptionsWidget { } // Check for Ollama configuration if it's in the precedence list - const ollamaWarnings = []; + const ollamaWarnings: string[] = []; if (providerPrecedence.includes('ollama')) { const ollamaBaseUrl = this.$widget.find('.ollama-base-url').val(); if (!ollamaBaseUrl) { @@ -234,7 +234,7 @@ export default class AiSettingsWidget extends OptionsWidget { } // Similar checks for embeddings - const embeddingWarnings = []; + const embeddingWarnings: string[] = []; const embeddingsEnabled = this.$widget.find('.enable-automatic-indexing').prop('checked'); if (embeddingsEnabled) { diff --git a/apps/client/src/widgets/view_widgets/calendar_view.ts b/apps/client/src/widgets/view_widgets/calendar_view.ts index fdc693dc1..d6eafa791 100644 --- a/apps/client/src/widgets/view_widgets/calendar_view.ts +++ b/apps/client/src/widgets/view_widgets/calendar_view.ts @@ -83,6 +83,13 @@ interface CreateChildResponse { }; } +interface Event { + startDate: string, + endDate?: string | null, + startTime?: string | null, + endTime?: string | null +} + const CALENDAR_VIEWS = [ "timeGridWeek", "dayGridMonth", @@ -325,8 +332,8 @@ export default class CalendarView extends ViewMode { } #parseStartEndTimeFromEvent(e: DateSelectArg | EventImpl) { - let startTime = null; - let endTime = null; + let startTime: string | undefined | null = null; + let endTime: string | undefined | null = null; if (!e.allDay) { startTime = CalendarView.#formatTimeToLocalISO(e.start); endTime = CalendarView.#formatTimeToLocalISO(e.end); @@ -391,7 +398,7 @@ export default class CalendarView extends ViewMode { } async #buildEventsForCalendar(e: EventSourceFuncArg) { - const events = []; + const events: EventInput[] = []; // Gather all the required date note IDs. const dateRange = utils.getMonthsInDateRange(e.startStr, e.endStr); @@ -483,12 +490,7 @@ export default class CalendarView extends ViewMode { return note.getLabelValue(defaultLabelName); } - static async buildEvent(note: FNote, { startDate, endDate, startTime, endTime }: { - startDate: string, - endDate?: string | null, - startTime?: string | null, - endTime?: string | null - }) { + static async buildEvent(note: FNote, { startDate, endDate, startTime, endTime }: Event) { const customTitleAttributeName = note.getLabelValue("calendar:title"); const titles = await CalendarView.#parseCustomTitle(customTitleAttributeName, note); const color = note.getLabelValue("calendar:color") ?? note.getLabelValue("color"); @@ -553,7 +555,7 @@ export default class CalendarView extends ViewMode { if (relations.length > 0) { const noteIds = relations.map((r) => r.targetNoteId); const notesFromRelation = await froca.getNotes(noteIds); - const titles = []; + const titles: string[][] = []; for (const targetNote of notesFromRelation) { const targetCustomTitleValue = targetNote.getAttributeValue("label", "calendar:title"); @@ -631,7 +633,7 @@ export default class CalendarView extends ViewMode { // Icon button. const iconEl = subItem.querySelector("span.fc-icon"); - let icon = null; + let icon: string | null = null; if (iconEl?.classList.contains("fc-icon-chevron-left")) { icon = "NSImageNameTouchBarGoBackTemplate"; mode = "buttons";