mirror of
https://github.com/jackwener/OpenCLI.git
synced 2026-09-14 18:25:42 +08:00
810547c9a9
Replace explicit `any` with `unknown` + narrowing or concrete types across
all core src/ files (non-`clis/**`). Core drops from ~60 `any` occurrences
to a handful of documented, unavoidable boundaries.
Mechanical error-handler cleanup (uses getErrorMessage() from errors.ts):
- cli.ts, cascade.ts, download/*.ts, external.ts, plugin.ts, doctor.ts
— catch (err: any) → catch (err) + getErrorMessage(err)
Pipeline steps — typed params with per-step interfaces:
- pipeline/steps/intercept.ts — InterceptParams, signature uses unknown
- pipeline/steps/tap.ts — TapParams
- pipeline/steps/download.ts — DownloadParams + DownloadedItem
(ytdlp_args is now coerced via String(v) for defence-in-depth)
Probe / boundary typing:
- cascade.ts — FetchProbeResponse interface; also fixes a latent bug
where result.success could be assigned undefined (masked by any)
by wrapping with !!(…)
Browser-side injected scripts — structural types at the TS boundary
(types stripped by tsc emit before .toString() runs, runtime unchanged):
- scripts/store.ts — PiniaStore / VuexModule / VueApp
- scripts/framework.ts — VueAppEl / FrameworkWindow
Runtime detection:
- runtime-detect.ts — BunGlobal interface; getRuntimeVersion reads Bun
into a local to avoid non-null assertions.
Test files — precise structural casts replacing `as any`:
- browser.test.ts — `{ _state: string }` cast for private
state; full DaemonStatus shape for
the getDaemonHealth mock
- browser/dom-helpers.test.ts — globalThis as Record<string, unknown>
- browser/cdp.test.ts — (...args: unknown[]) in mock handlers
- runtime-detect.test.ts — matches runtime-detect.ts BunGlobal
- output.test.ts — logSpy.mock.calls typed with unknown[]
- engine.test.ts, snapshotFormatter.test.ts, pipeline/executor.test.ts
— narrow structural casts / removed stale any casts
Verification:
- npx tsc --noEmit: clean
- npx vitest run (excluding e2e/smoke): 1415 passed, 1 skipped