fix: replace any types with proper TypeScript types

Replace all `any` types with properly defined TypeScript interfaces and types throughout the codebase to improve type safety and eliminate type-related code quality issues.

Changes:
- Define ElectronSafeStorage interface for Electron's safeStorage API
- Create LegacySettings interface for settings migration in main.ts
- Define JSONValue, JSONRPCParams types for JSON-RPC protocol
- Define JSONSchemaProperty for tool input schemas
- Create YAMLValue type for frontmatter values
- Define FrontmatterValue type for adapter interfaces
- Update middleware to use proper Express NextFunction and JSONRPCResponse types
- Fix tool registry to handle args with proper typing (with eslint-disable for dynamic dispatch)
- Fix notifications to use proper types with eslint-disable where dynamic access is needed
- Add proper null safety assertions where appropriate
- Fix TFolder stat access with proper type extension

All type errors resolved. TypeScript compilation passes with --skipLibCheck.
This commit is contained in:
2025-11-07 11:10:52 -05:00
parent b0fc0be629
commit 2a7fce45af
13 changed files with 127 additions and 50 deletions

View File

@@ -1,5 +1,5 @@
import { FileManager, TAbstractFile, TFile } from 'obsidian';
import { IFileManagerAdapter } from './interfaces';
import { IFileManagerAdapter, FrontmatterValue } from './interfaces';
export class FileManagerAdapter implements IFileManagerAdapter {
constructor(private fileManager: FileManager) {}
@@ -12,7 +12,7 @@ export class FileManagerAdapter implements IFileManagerAdapter {
await this.fileManager.trashFile(file);
}
async processFrontMatter(file: TFile, fn: (frontmatter: any) => void): Promise<void> {
async processFrontMatter(file: TFile, fn: (frontmatter: Record<string, FrontmatterValue>) => void): Promise<void> {
await this.fileManager.processFrontMatter(file, fn);
}
}

View File

@@ -1,5 +1,10 @@
import { TAbstractFile, TFile, TFolder, CachedMetadata, DataWriteOptions } from 'obsidian';
/**
* Frontmatter data structure (YAML-compatible types)
*/
export type FrontmatterValue = string | number | boolean | null | FrontmatterValue[] | { [key: string]: FrontmatterValue };
/**
* Adapter interface for Obsidian Vault operations
*/
@@ -56,5 +61,5 @@ export interface IFileManagerAdapter {
// File operations
renameFile(file: TAbstractFile, newPath: string): Promise<void>;
trashFile(file: TAbstractFile): Promise<void>;
processFrontMatter(file: TFile, fn: (frontmatter: any) => void): Promise<void>;
processFrontMatter(file: TFile, fn: (frontmatter: Record<string, FrontmatterValue>) => void): Promise<void>;
}