fix: remove 8 more unnecessary as any casts in opencode core (#22877)

This commit is contained in:
Kit Langton
2026-04-16 15:27:53 -04:00
committed by GitHub
parent 219b473e66
commit 2fe9d94470
8 changed files with 16 additions and 13 deletions

View File

@@ -178,7 +178,7 @@ export namespace ACP {
})
for await (const event of events.stream) {
if (this.eventAbort.signal.aborted) return
const payload = (event as any)?.payload
const payload = event?.payload
if (!payload) continue
await this.handleEvent(payload as Event).catch((error) => {
log.error("failed to handle event", { error, type: payload.type })

View File

@@ -297,7 +297,9 @@ export const ProvidersLoginCommand = cmd({
prompts.intro("Add credential")
if (args.url) {
const url = args.url.replace(/\/+$/, "")
const wellknown = await fetch(`${url}/.well-known/opencode`).then((x) => x.json() as any)
const wellknown = (await fetch(`${url}/.well-known/opencode`).then((x) => x.json())) as {
auth: { command: string[]; env: string }
}
prompts.log.info(`Running \`${wellknown.auth.command.join(" ")}\``)
const proc = Process.spawn(wellknown.auth.command, {
stdout: "pipe",

View File

@@ -1,4 +1,5 @@
import { dlopen, ptr } from "bun:ffi"
import type { ReadStream } from "node:tty"
const STD_INPUT_HANDLE = -10
const ENABLE_PROCESSED_INPUT = 0x0001
@@ -71,7 +72,7 @@ export function win32InstallCtrlCGuard() {
if (!load()) return
if (unhook) return unhook
const stdin = process.stdin as any
const stdin = process.stdin as ReadStream
const original = stdin.setRawMode
const handle = k32!.symbols.GetStdHandle(STD_INPUT_HANDLE)
@@ -93,7 +94,7 @@ export function win32InstallCtrlCGuard() {
setImmediate(enforce)
}
let wrapped: ((mode: boolean) => unknown) | undefined
let wrapped: ReadStream["setRawMode"] | undefined
if (typeof original === "function") {
wrapped = (mode: boolean) => {

View File

@@ -465,12 +465,12 @@ export const layer = Layer.effect(
direction: "callHierarchy/incomingCalls" | "callHierarchy/outgoingCalls",
) {
const results = yield* run(input.file, async (client) => {
const items = (await client.connection
.sendRequest("textDocument/prepareCallHierarchy", {
const items = await client.connection
.sendRequest<unknown[] | null>("textDocument/prepareCallHierarchy", {
textDocument: { uri: pathToFileURL(input.file).href },
position: { line: input.line, character: input.character },
})
.catch(() => [])) as any[]
.catch(() => [] as unknown[])
if (!items?.length) return []
return client.connection.sendRequest(direction, { item: items[0] }).catch(() => [])
})

View File

@@ -531,7 +531,7 @@ export const layer = Layer.effect(
Object.values(s.clients),
(client) =>
Effect.gen(function* () {
const pid = (client.transport as any)?.pid
const pid = client.transport instanceof StdioClientTransport ? client.transport.pid : null
if (typeof pid === "number") {
const pids = yield* descendants(pid)
for (const dpid of pids) {

View File

@@ -354,7 +354,7 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
details: "flex processing is only available for o3, o4-mini, and gpt-5 models",
})
// Remove from args if not supported
delete (baseArgs as any).service_tier
baseArgs.service_tier = undefined
}
// Validate priority processing support
@@ -366,7 +366,7 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
"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",
})
// Remove from args if not supported
delete (baseArgs as any).service_tier
baseArgs.service_tier = undefined
}
const {

View File

@@ -193,7 +193,7 @@ function normalizeMessages(
providerOptions: {
...msg.providerOptions,
openaiCompatible: {
...(msg.providerOptions as any)?.openaiCompatible,
...msg.providerOptions?.openaiCompatible,
[field]: reasoningText,
},
},

View File

@@ -77,8 +77,8 @@ function union(ast: SchemaAST.Union): z.ZodTypeAny {
if (items.length === 1) return items[0]
if (items.length < 2) return fail(ast)
const discriminator = (ast as any).annotations?.discriminator
if (discriminator) {
const discriminator = ast.annotations?.discriminator
if (typeof discriminator === "string") {
return z.discriminatedUnion(discriminator, items as [z.ZodObject<any>, z.ZodObject<any>, ...z.ZodObject<any>[]])
}