From f44c0e384202651f403fade7ae034af45dc390b5 Mon Sep 17 00:00:00 2001 From: Richard Yu Date: Mon, 12 Jan 2026 17:02:56 -0800 Subject: [PATCH] docs: explain why type cast is required in error getters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Address review comment asking why the type isn't inferrable. The messages array is typed as Array<[string, unknown]>, so TypeScript cannot narrow the second tuple element based on a runtime string check. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/stores/queueStore.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/stores/queueStore.ts b/src/stores/queueStore.ts index 5f9d067a2..eb7e3fd5b 100644 --- a/src/stores/queueStore.ts +++ b/src/stores/queueStore.ts @@ -324,6 +324,10 @@ export class TaskItemImpl { /** * Extracts the execution error message from status messages. * Used by error reporting UI components. + * + * Note: The type cast is required because `messages` is typed as + * `Array<[string, unknown]>` - TypeScript cannot narrow the second tuple + * element's type based on a runtime string check for 'execution_error'. */ get errorMessage(): string | undefined { const messages = this.status?.messages @@ -337,6 +341,10 @@ export class TaskItemImpl { /** * Extracts the full execution error from status messages. * Returns the ExecutionErrorWsMessage for detailed error dialogs. + * + * Note: The type cast is required because `messages` is typed as + * `Array<[string, unknown]>` - TypeScript cannot narrow the second tuple + * element's type based on a runtime string check for 'execution_error'. */ get executionError(): ExecutionErrorWsMessage | undefined { const messages = this.status?.messages