From 143097a9736c54d2ec10f9b99d1463a8246c6ea9 Mon Sep 17 00:00:00 2001 From: Jarvis Date: Sun, 21 Sep 2025 08:02:16 +0200 Subject: [PATCH] fix: improve TypeScript type safety MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replace any types with proper Obsidian API types - Add App type import for better type safety - Add ButtonComponent type for settings button parameter - Add null safety for button text content - Remove redundant "Settings" from settings tab heading 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- commands/notePrompts.ts | 4 ++-- settings.ts | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/commands/notePrompts.ts b/commands/notePrompts.ts index a592e65..ca09b3a 100644 --- a/commands/notePrompts.ts +++ b/commands/notePrompts.ts @@ -1,7 +1,7 @@ // ABOUTME: Note prompts command implementation that appends prompts to the current note // ABOUTME: Handles editor interaction, cursor positioning, and prompt formatting -import { Editor, MarkdownView, Notice } from 'obsidian'; +import { App, Editor, MarkdownView, Notice } from 'obsidian'; import { PromptGeneratorService } from '../services/promptGenerator'; import { FreewritingPromptsSettings } from '../types'; @@ -107,7 +107,7 @@ export class NotePromptsCommand { return !!(editor && view && view.file); } - static getExecutionContext(app: any): { editor: Editor | null; view: MarkdownView | null } { + static getExecutionContext(app: App): { editor: Editor | null; view: MarkdownView | null } { const activeView = app.workspace.getActiveViewOfType(MarkdownView); if (!activeView) { diff --git a/settings.ts b/settings.ts index 7302cfe..bfb1ef3 100644 --- a/settings.ts +++ b/settings.ts @@ -1,7 +1,7 @@ // ABOUTME: Settings interface and SettingTab implementation for the Freewriting Prompts plugin // ABOUTME: Handles user configuration including API key, model selection, and prompt customization -import { App, Notice, PluginSettingTab, Setting } from 'obsidian'; +import { App, ButtonComponent, Notice, PluginSettingTab, Setting } from 'obsidian'; import FreewritingPromptsPlugin from './main'; import { FreewritingPromptsSettings, ANTHROPIC_MODELS, AnthropicModel } from './types'; @@ -28,7 +28,7 @@ export class FreewritingPromptsSettingTab extends PluginSettingTab { const { containerEl } = this; containerEl.empty(); - containerEl.createEl('h2', { text: 'Freewriting Prompts Settings' }); + containerEl.createEl('h2', { text: 'Freewriting Prompts' }); // MARK: - API Configuration @@ -185,8 +185,8 @@ export class FreewritingPromptsSettingTab extends PluginSettingTab { // MARK: - API Testing - private async testApiKey(button: any): Promise { - const originalText = button.buttonEl.textContent; + private async testApiKey(button: ButtonComponent): Promise { + const originalText = button.buttonEl.textContent || 'Test Connection'; // Update button to show loading state button.setButtonText('Testing...');