summaryrefslogtreecommitdiffhomepage
path: root/packages
diff options
context:
space:
mode:
authorKit Langton <[email protected]>2026-04-16 15:07:02 -0400
committerGitHub <[email protected]>2026-04-16 15:07:02 -0400
commitbf4c1078290a5bf7e580141b17e7b37d905de311 (patch)
tree19c5e1daa9b593c5e620d57ee8b2abfb4b11e0c1 /packages
parent9afbdc102c2e7e449c98a08082b382cd2696715e (diff)
downloadopencode-bf4c1078290a5bf7e580141b17e7b37d905de311.tar.gz
opencode-bf4c1078290a5bf7e580141b17e7b37d905de311.zip
fix: remove 7 unnecessary `as any` casts in opencode core (#22840)
Diffstat (limited to 'packages')
-rw-r--r--packages/opencode/src/cli/cmd/tui/routes/session/index.tsx2
-rw-r--r--packages/opencode/src/storage/json-migration.ts12
-rw-r--r--packages/opencode/src/util/defer.ts6
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 1a64c21d0..5b4308d59 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 4803d452f..12133ce43 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<any, any> | NodeSQLiteDatabase<a
return items
}
- function insert(values: any[], table: any, label: string) {
+ function insert(values: unknown[], table: Parameters<typeof db.insert>[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<any, any> | NodeSQLiteDatabase<a
// Migrate projects first (no FK deps)
// Derive all IDs from file paths, not JSON content
const projectIds = new Set<string>()
- 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<any, any> | NodeSQLiteDatabase<a
// migrations may have moved sessions to new directories without updating the JSON
const sessionProjects = sessionFiles.map((file) => path.basename(path.dirname(file)))
const sessionIds = new Set<string>()
- 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<any, any> | NodeSQLiteDatabase<a
for (let i = 0; i < todoFiles.length; i += batchSize) {
const end = Math.min(i + batchSize, todoFiles.length)
const batch = await read(todoFiles, i, end)
- const values = [] as any[]
+ const values: unknown[] = []
for (let j = 0; j < batch.length; j++) {
const data = batch[j]
if (!data) continue
@@ -351,7 +351,7 @@ export async function run(db: SQLiteBunDatabase<any, any> | NodeSQLiteDatabase<a
// Migrate permissions
const permProjects = permFiles.map((file) => 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<any, any> | NodeSQLiteDatabase<a
// Migrate session shares
const shareSessions = shareFiles.map((file) => 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 d1c9edc66..33eb4d74d 100644
--- a/packages/opencode/src/util/defer.ts
+++ b/packages/opencode/src/util/defer.ts
@@ -1,6 +1,4 @@
-export function defer<T extends () => void | Promise<void>>(
- fn: T,
-): T extends () => Promise<void> ? { [Symbol.asyncDispose]: () => Promise<void> } : { [Symbol.dispose]: () => void } {
+export function defer(fn: () => void | Promise<void>): AsyncDisposable & Disposable {
return {
[Symbol.dispose]() {
void fn()
@@ -8,5 +6,5 @@ export function defer<T extends () => void | Promise<void>>(
[Symbol.asyncDispose]() {
return Promise.resolve(fn())
},
- } as any
+ }
}