Skip to content

Commit 6c74ba4

Browse files
terisukeclaude
andcommitted
fix(hook): use HookResult type for catch return to fix type errors (#80)
The .catch() handlers on PostToolUse runHooks calls returned { action: "pass" } without message property, causing TS2339 when accessing .message on the union type. Using HookResult as the return type resolves this since it includes message?: string. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
1 parent b01ee2b commit 6c74ba4

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎packages/opencode/src/session/prompt.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ import { Shell } from "@/shell/shell"
4848
import { AppFileSystem } from "@/filesystem"
4949
import { Truncate } from "@/tool/truncate"
5050
import { decodeDataUrl } from "@/util/data-url"
51-
import { runHooks, safeToolInput, type HookEnv } from "../hook"
51+
import { runHooks, safeToolInput, type HookEnv, type HookResult } from "../hook"
5252
import { Config } from "../config/config"
5353
import { Process } from "@/util/process"
5454
import { Cause, Effect, Exit, Layer, Option, Scope, ServiceMap } from "effect"
@@ -513,7 +513,7 @@ NOTE: At any point in time through this workflow you should feel free to ask the
513513
runHooks(hookCfg.hooks?.PostToolUse, item.id, {
514514
...hookEnv,
515515
OPENCODE_HOOK_EVENT: "PostToolUse",
516-
}).catch((): { action: "pass" } => ({ action: "pass" })),
516+
}).catch((): HookResult => ({ action: "pass" })),
517517
)
518518

519519
if (postHookResult.action === "block") {
@@ -591,7 +591,7 @@ NOTE: At any point in time through this workflow you should feel free to ask the
591591
runHooks(mcpHookCfg.hooks?.PostToolUse, key, {
592592
...mcpHookEnv,
593593
OPENCODE_HOOK_EVENT: "PostToolUse",
594-
}).catch((): { action: "pass" } => ({ action: "pass" })),
594+
}).catch((): HookResult => ({ action: "pass" })),
595595
)
596596

597597
if (mcpPostResult.action === "block") {

0 commit comments

Comments
 (0)