Skip to content

Commit 2fe9d94

Browse files
authored
fix: remove 8 more unnecessary as any casts in opencode core (#22877)
1 parent 219b473 commit 2fe9d94

8 files changed

Lines changed: 16 additions & 13 deletions

File tree

packages/opencode/src/acp/agent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ export namespace ACP {
178178
})
179179
for await (const event of events.stream) {
180180
if (this.eventAbort.signal.aborted) return
181-
const payload = (event as any)?.payload
181+
const payload = event?.payload
182182
if (!payload) continue
183183
await this.handleEvent(payload as Event).catch((error) => {
184184
log.error("failed to handle event", { error, type: payload.type })

packages/opencode/src/cli/cmd/providers.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,9 @@ export const ProvidersLoginCommand = cmd({
297297
prompts.intro("Add credential")
298298
if (args.url) {
299299
const url = args.url.replace(/\/+$/, "")
300-
const wellknown = await fetch(`${url}/.well-known/opencode`).then((x) => x.json() as any)
300+
const wellknown = (await fetch(`${url}/.well-known/opencode`).then((x) => x.json())) as {
301+
auth: { command: string[]; env: string }
302+
}
301303
prompts.log.info(`Running \`${wellknown.auth.command.join(" ")}\``)
302304
const proc = Process.spawn(wellknown.auth.command, {
303305
stdout: "pipe",

packages/opencode/src/cli/cmd/tui/win32.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { dlopen, ptr } from "bun:ffi"
2+
import type { ReadStream } from "node:tty"
23

34
const STD_INPUT_HANDLE = -10
45
const ENABLE_PROCESSED_INPUT = 0x0001
@@ -71,7 +72,7 @@ export function win32InstallCtrlCGuard() {
7172
if (!load()) return
7273
if (unhook) return unhook
7374

74-
const stdin = process.stdin as any
75+
const stdin = process.stdin as ReadStream
7576
const original = stdin.setRawMode
7677

7778
const handle = k32!.symbols.GetStdHandle(STD_INPUT_HANDLE)
@@ -93,7 +94,7 @@ export function win32InstallCtrlCGuard() {
9394
setImmediate(enforce)
9495
}
9596

96-
let wrapped: ((mode: boolean) => unknown) | undefined
97+
let wrapped: ReadStream["setRawMode"] | undefined
9798

9899
if (typeof original === "function") {
99100
wrapped = (mode: boolean) => {

packages/opencode/src/lsp/lsp.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,12 +465,12 @@ export const layer = Layer.effect(
465465
direction: "callHierarchy/incomingCalls" | "callHierarchy/outgoingCalls",
466466
) {
467467
const results = yield* run(input.file, async (client) => {
468-
const items = (await client.connection
469-
.sendRequest("textDocument/prepareCallHierarchy", {
468+
const items = await client.connection
469+
.sendRequest<unknown[] | null>("textDocument/prepareCallHierarchy", {
470470
textDocument: { uri: pathToFileURL(input.file).href },
471471
position: { line: input.line, character: input.character },
472472
})
473-
.catch(() => [])) as any[]
473+
.catch(() => [] as unknown[])
474474
if (!items?.length) return []
475475
return client.connection.sendRequest(direction, { item: items[0] }).catch(() => [])
476476
})

packages/opencode/src/mcp/mcp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ export const layer = Layer.effect(
531531
Object.values(s.clients),
532532
(client) =>
533533
Effect.gen(function* () {
534-
const pid = (client.transport as any)?.pid
534+
const pid = client.transport instanceof StdioClientTransport ? client.transport.pid : null
535535
if (typeof pid === "number") {
536536
const pids = yield* descendants(pid)
537537
for (const dpid of pids) {

packages/opencode/src/provider/sdk/copilot/responses/openai-responses-language-model.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
354354
details: "flex processing is only available for o3, o4-mini, and gpt-5 models",
355355
})
356356
// Remove from args if not supported
357-
delete (baseArgs as any).service_tier
357+
baseArgs.service_tier = undefined
358358
}
359359

360360
// Validate priority processing support
@@ -366,7 +366,7 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
366366
"priority processing is only available for supported models (gpt-4, gpt-5, gpt-5-mini, o3, o4-mini) and requires Enterprise access. gpt-5-nano is not supported",
367367
})
368368
// Remove from args if not supported
369-
delete (baseArgs as any).service_tier
369+
baseArgs.service_tier = undefined
370370
}
371371

372372
const {

packages/opencode/src/provider/transform.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ function normalizeMessages(
193193
providerOptions: {
194194
...msg.providerOptions,
195195
openaiCompatible: {
196-
...(msg.providerOptions as any)?.openaiCompatible,
196+
...msg.providerOptions?.openaiCompatible,
197197
[field]: reasoningText,
198198
},
199199
},

packages/opencode/src/util/effect-zod.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ function union(ast: SchemaAST.Union): z.ZodTypeAny {
7777
if (items.length === 1) return items[0]
7878
if (items.length < 2) return fail(ast)
7979

80-
const discriminator = (ast as any).annotations?.discriminator
81-
if (discriminator) {
80+
const discriminator = ast.annotations?.discriminator
81+
if (typeof discriminator === "string") {
8282
return z.discriminatedUnion(discriminator, items as [z.ZodObject<any>, z.ZodObject<any>, ...z.ZodObject<any>[]])
8383
}
8484

0 commit comments

Comments
 (0)