refactor: eliminate any types across server and TTS worker

- app.ts: type serveFile context parameter as Hono Context
- bets.ts: replace catch(err: any) with err: unknown + narrowing
- fight-loop.ts: type pickMatchup style as union literal, replace
  as any casts with proper result type
- tts-worker.ts: import KokoroTTS type, use ProgressInfo inference

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dorian
2026-03-08 20:34:11 +00:00
co-authored by Claude Opus 4.6
parent 1ca8a6feb0
commit 010e18fbd3
4 changed files with 12 additions and 10 deletions
+5 -3
View File
@@ -1,7 +1,9 @@
// Web Worker for Kokoro TTS — runs ONNX neural network inference off the main thread.
// This prevents the 1-5 second freezes that occur when generate() runs on the UI thread.
let tts: any = null
import type { KokoroTTS } from 'kokoro-js'
let tts: KokoroTTS | null = null
self.addEventListener('message', async (e: MessageEvent) => {
const msg = e.data
@@ -13,8 +15,8 @@ self.addEventListener('message', async (e: MessageEvent) => {
tts = await KokoroTTS.from_pretrained('onnx-community/Kokoro-82M-ONNX', {
dtype: 'q8',
device: null,
progress_callback: (p: any) => {
if (p.progress !== undefined) {
progress_callback: (p) => {
if ('progress' in p && typeof p.progress === 'number') {
self.postMessage({ type: 'progress', progress: p.progress })
}
},