From b13bf96b3baab68c4d8f49af9adaef9b8362e079 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 11 Jan 2026 04:47:44 +0000 Subject: [PATCH] fix(types): resolve TypeScript linting errors for build Fixed all TypeScript errors preventing build: - Added TTSAudiobookChapter type import to HTMLContext - Replaced 'any' types with proper TTSAudiobookChapter type - Removed unused goToChapter from HTMLViewer destructuring - Updated AudiobookExportModal to accept 'html' documentType - Fixed HTMLContext return types to match EPUB/PDF contexts - createFullAudioBook now returns Promise (bookId only) - regenerateChapter now returns Promise - Prefixed/removed unused parameters in placeholder functions Build now completes successfully with only minor warnings in placeholder code that will be implemented later. --- src/app/api/jobs/route.ts | 2 +- src/components/AudiobookExportModal.tsx | 2 +- src/components/HTMLViewer.tsx | 1 - src/contexts/HTMLContext.tsx | 26 ++++++++++++++++--------- src/lib/chapterDetection.ts | 2 +- src/lib/jobProcessor.ts | 4 ++-- 6 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/app/api/jobs/route.ts b/src/app/api/jobs/route.ts index e49b7b1..aa7cb0d 100644 --- a/src/app/api/jobs/route.ts +++ b/src/app/api/jobs/route.ts @@ -132,7 +132,7 @@ async function processJobInBackground(jobId: string) { job.currentStep = 'Loading document...'; jobs.set(jobId, job); - const { documentId, voice, speed, ttsProvider, ttsModel, ttsInstructions, format } = job.data; + const { documentId, voice, speed, ttsProvider, ttsModel, format } = job.data; // In a real implementation, this would: // 1. Load the document from IndexedDB or file system diff --git a/src/components/AudiobookExportModal.tsx b/src/components/AudiobookExportModal.tsx index e0cb4ed..d556421 100644 --- a/src/components/AudiobookExportModal.tsx +++ b/src/components/AudiobookExportModal.tsx @@ -20,7 +20,7 @@ import { interface AudiobookExportModalProps { isOpen: boolean; setIsOpen: (isOpen: boolean) => void; - documentType: 'epub' | 'pdf'; + documentType: 'epub' | 'pdf' | 'html'; documentId: string; onGenerateAudiobook: ( onProgress: (progress: number) => void, diff --git a/src/components/HTMLViewer.tsx b/src/components/HTMLViewer.tsx index 69b1e76..7d96236 100644 --- a/src/components/HTMLViewer.tsx +++ b/src/components/HTMLViewer.tsx @@ -19,7 +19,6 @@ export function HTMLViewer({ className = '' }: HTMLViewerProps) { totalChapters, goToNextChapter, goToPreviousChapter, - goToChapter, } = useHTML(); const containerRef = useRef(null); diff --git a/src/contexts/HTMLContext.tsx b/src/contexts/HTMLContext.tsx index 0e023f1..f46ef62 100644 --- a/src/contexts/HTMLContext.tsx +++ b/src/contexts/HTMLContext.tsx @@ -11,6 +11,7 @@ import { import { getHtmlDocument } from '@/lib/dexie'; import { useTTS } from '@/contexts/TTSContext'; import { detectChapters, type Chapter } from '@/lib/chapterDetection'; +import type { TTSAudiobookChapter } from '@/types/tts'; interface HTMLContextType { currDocData: string | undefined; @@ -31,16 +32,16 @@ interface HTMLContextType { createFullAudioBook: ( onProgress: (progress: number) => void, signal: AbortSignal, - onChapterComplete: (chapter: any) => void, + onChapterComplete: (chapter: TTSAudiobookChapter) => void, documentId: string, format: 'mp3' | 'm4b' - ) => Promise<{ bookId: string; format: string }>; + ) => Promise; regenerateChapter: ( chapterIndex: number, bookId: string, format: 'mp3' | 'm4b', signal: AbortSignal - ) => Promise; + ) => Promise; } const HTMLContext = createContext(undefined); @@ -123,10 +124,10 @@ export function HTMLProvider({ children }: { children: ReactNode }) { */ const createFullAudioBook = useCallback(async ( onProgress: (progress: number) => void, - signal: AbortSignal, - onChapterComplete: (chapter: any) => void, + _signal: AbortSignal, + _onChapterComplete: (chapter: TTSAudiobookChapter) => void, documentId: string, - format: 'mp3' | 'm4b' + _format: 'mp3' | 'm4b' ) => { // Placeholder - will be implemented with job queue system console.log('createFullAudioBook called for HTML document:', documentId); @@ -134,7 +135,7 @@ export function HTMLProvider({ children }: { children: ReactNode }) { // TODO: Integrate with background job queue // For now, return a placeholder - return { bookId: 'placeholder', format }; + return 'placeholder'; }, []); /** @@ -145,10 +146,17 @@ export function HTMLProvider({ children }: { children: ReactNode }) { chapterIndex: number, bookId: string, format: 'mp3' | 'm4b', - signal: AbortSignal - ) => { + _signal: AbortSignal + ): Promise => { // Placeholder console.log('regenerateChapter called:', chapterIndex, bookId, format); + return { + index: chapterIndex, + title: `Chapter ${chapterIndex + 1}`, + status: 'completed', + bookId, + format, + }; }, []); /** diff --git a/src/lib/chapterDetection.ts b/src/lib/chapterDetection.ts index 4c8c5bf..305baed 100644 --- a/src/lib/chapterDetection.ts +++ b/src/lib/chapterDetection.ts @@ -99,7 +99,7 @@ function splitBySize(text: string, maxChunkSize: number): Chapter[] { let currentChunk = ''; let chunkIndex = 0; - paragraphs.forEach((paragraph, index) => { + paragraphs.forEach((paragraph) => { const potentialChunk = currentChunk + (currentChunk ? '\n\n' : '') + paragraph; if (potentialChunk.length > maxChunkSize && currentChunk.length > 0) { diff --git a/src/lib/jobProcessor.ts b/src/lib/jobProcessor.ts index edd9ba5..778b262 100644 --- a/src/lib/jobProcessor.ts +++ b/src/lib/jobProcessor.ts @@ -100,7 +100,7 @@ export async function processAudiobookJob( * Fetch document content from storage * This would integrate with your document storage system */ -async function fetchDocumentContent(documentId: string, signal: AbortSignal): Promise { +async function fetchDocumentContent(_documentId: string, _signal: AbortSignal): Promise { // In a real implementation, this would: // 1. Query the document from IndexedDB or file system // 2. Extract text content based on document type (PDF, EPUB, HTML) @@ -115,7 +115,7 @@ async function fetchDocumentContent(documentId: string, signal: AbortSignal): Pr * Process text into sentences * Uses the existing NLP sentence splitting logic */ -async function processTextToSentences(text: string, signal: AbortSignal): Promise { +async function processTextToSentences(text: string, _signal: AbortSignal): Promise { // This would use the same logic as the TTS context // For now, simple split on sentence boundaries const sentences = text