From bf4c1078290a5bf7e580141b17e7b37d905de311 Mon Sep 17 00:00:00 2001 From: Kit Langton Date: Thu, 16 Apr 2026 15:07:02 -0400 Subject: [PATCH] fix: remove 7 unnecessary `as any` casts in opencode core (#22840) --- .../src/cli/cmd/tui/routes/session/index.tsx | 2 +- packages/opencode/src/storage/json-migration.ts | 12 ++++++------ packages/opencode/src/util/defer.ts | 6 ++---- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx b/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx index 1a64c21d00..5b4308d593 100644 --- a/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx +++ b/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx @@ -597,7 +597,7 @@ export function Session() { { title: conceal() ? "Disable code concealment" : "Enable code concealment", value: "session.toggle.conceal", - keybind: "messages_toggle_conceal" as any, + keybind: "messages_toggle_conceal", category: "Session", onSelect: (dialog) => { setConceal((prev) => !prev) diff --git a/packages/opencode/src/storage/json-migration.ts b/packages/opencode/src/storage/json-migration.ts index 4803d452fe..12133ce435 100644 --- a/packages/opencode/src/storage/json-migration.ts +++ b/packages/opencode/src/storage/json-migration.ts @@ -95,7 +95,7 @@ export async function run(db: SQLiteBunDatabase | NodeSQLiteDatabase[0], label: string) { if (values.length === 0) return 0 try { db.insert(table).values(values).onConflictDoNothing().run() @@ -152,7 +152,7 @@ export async function run(db: SQLiteBunDatabase | NodeSQLiteDatabase() - const projectValues = [] as any[] + const projectValues: unknown[] = [] for (let i = 0; i < projectFiles.length; i += batchSize) { const end = Math.min(i + batchSize, projectFiles.length) const batch = await read(projectFiles, i, end) @@ -186,7 +186,7 @@ export async function run(db: SQLiteBunDatabase | NodeSQLiteDatabase path.basename(path.dirname(file))) const sessionIds = new Set() - const sessionValues = [] as any[] + const sessionValues: unknown[] = [] for (let i = 0; i < sessionFiles.length; i += batchSize) { const end = Math.min(i + batchSize, sessionFiles.length) const batch = await read(sessionFiles, i, end) @@ -314,7 +314,7 @@ export async function run(db: SQLiteBunDatabase | NodeSQLiteDatabase | NodeSQLiteDatabase path.basename(file, ".json")) - const permValues = [] as any[] + const permValues: unknown[] = [] for (let i = 0; i < permFiles.length; i += batchSize) { const end = Math.min(i + batchSize, permFiles.length) const batch = await read(permFiles, i, end) @@ -376,7 +376,7 @@ export async function run(db: SQLiteBunDatabase | NodeSQLiteDatabase path.basename(file, ".json")) - const shareValues = [] as any[] + const shareValues: unknown[] = [] for (let i = 0; i < shareFiles.length; i += batchSize) { const end = Math.min(i + batchSize, shareFiles.length) const batch = await read(shareFiles, i, end) diff --git a/packages/opencode/src/util/defer.ts b/packages/opencode/src/util/defer.ts index d1c9edc66a..33eb4d74d2 100644 --- a/packages/opencode/src/util/defer.ts +++ b/packages/opencode/src/util/defer.ts @@ -1,6 +1,4 @@ -export function defer void | Promise>( - fn: T, -): T extends () => Promise ? { [Symbol.asyncDispose]: () => Promise } : { [Symbol.dispose]: () => void } { +export function defer(fn: () => void | Promise): AsyncDisposable & Disposable { return { [Symbol.dispose]() { void fn() @@ -8,5 +6,5 @@ export function defer void | Promise>( [Symbol.asyncDispose]() { return Promise.resolve(fn()) }, - } as any + } }