fix(tsc): Phase 3b — fix 21 type errors in PowerShell/Bash/MCP UI (141→120)

This commit is contained in:
James Feng 2026-06-07 11:08:03 +08:00
parent 2c0a35d04b
commit 76965c5e8c
3 changed files with 46 additions and 5 deletions

View File

@ -17,6 +17,21 @@ import { getDisplayPath } from 'src/utils/file.js'
import { isFullscreenEnvEnabled } from 'src/utils/fullscreen.js' import { isFullscreenEnvEnabled } from 'src/utils/fullscreen.js'
import type { ThemeName } from 'src/utils/theme.js' import type { ThemeName } from 'src/utils/theme.js'
import type { BashProgress, BashToolInput, Out } from '@claude-code-best/builtin-tools/tools/BashTool/BashTool.js' import type { BashProgress, BashToolInput, Out } from '@claude-code-best/builtin-tools/tools/BashTool/BashTool.js'
/**
* Local type describing the actual runtime shape of Bash progress data.
* BashProgress is `Record<string, unknown>`, so we need a concrete shape
* for property access without resorting to `as any`.
*/
type BashProgressData = {
fullOutput?: string
output?: string
elapsedTimeSeconds?: number
totalLines?: number
totalBytes?: number
timeoutMs?: number
taskId?: string
}
import BashToolResultMessage from '@claude-code-best/builtin-tools/tools/BashTool/BashToolResultMessage.js' import BashToolResultMessage from '@claude-code-best/builtin-tools/tools/BashTool/BashToolResultMessage.js'
import { extractBashCommentLabel } from '@claude-code-best/builtin-tools/tools/BashTool/commentLabel.js' import { extractBashCommentLabel } from '@claude-code-best/builtin-tools/tools/BashTool/commentLabel.js'
import { parseSedEditCommand } from '@claude-code-best/builtin-tools/tools/BashTool/sedEditParser.js' import { parseSedEditCommand } from '@claude-code-best/builtin-tools/tools/BashTool/sedEditParser.js'
@ -147,7 +162,7 @@ export function renderToolUseProgressMessage(
) )
} }
const data = lastProgress.data const data = lastProgress.data as BashProgressData
return ( return (
<ShellProgressMessage <ShellProgressMessage
@ -187,7 +202,7 @@ export function renderToolResultMessage(
}, },
): React.ReactNode { ): React.ReactNode {
const lastProgress = progressMessagesForMessage.at(-1) const lastProgress = progressMessagesForMessage.at(-1)
const timeoutMs = lastProgress?.data?.timeoutMs const timeoutMs = (lastProgress?.data as BashProgressData | undefined)?.timeoutMs
return ( return (
<BashToolResultMessage <BashToolResultMessage
content={content} content={content}

View File

@ -16,6 +16,17 @@ import { getContentSizeEstimate, type MCPToolResult } from 'src/utils/mcpValidat
import { jsonParse, jsonStringify } from 'src/utils/slowOperations.js'; import { jsonParse, jsonStringify } from 'src/utils/slowOperations.js';
import type { inputSchema } from './MCPTool.js'; import type { inputSchema } from './MCPTool.js';
/**
* Local type describing the actual runtime shape of MCP progress data.
* MCPProgress is `Record<string, unknown>`, so we need a concrete shape
* for property access without resorting to `as any`.
*/
type MCPProgressData = {
progress?: number;
total?: number;
progressMessage?: string;
};
// Threshold for displaying warning about large MCP responses // Threshold for displaying warning about large MCP responses
const MCP_OUTPUT_WARNING_THRESHOLD_TOKENS = 10_000; const MCP_OUTPUT_WARNING_THRESHOLD_TOKENS = 10_000;
@ -69,7 +80,7 @@ export function renderToolUseProgressMessage(
); );
} }
const { progress, total, progressMessage } = lastProgress.data; const { progress, total, progressMessage } = lastProgress.data as MCPProgressData;
if (progress === undefined) { if (progress === undefined) {
return ( return (

View File

@ -13,6 +13,21 @@ import type { PowerShellProgress } from 'src/types/tools.js';
import type { ThemeName } from 'src/utils/theme.js'; import type { ThemeName } from 'src/utils/theme.js';
import type { Out, PowerShellToolInput } from './PowerShellTool.js'; import type { Out, PowerShellToolInput } from './PowerShellTool.js';
/**
* Local type describing the actual runtime shape of PowerShell progress data.
* PowerShellProgress is `Record<string, unknown>`, so we need a concrete shape
* for property access without resorting to `as any`.
*/
type PowerShellProgressData = {
fullOutput?: string;
output?: string;
elapsedTimeSeconds?: number;
totalLines?: number;
totalBytes?: number;
timeoutMs?: number;
taskId?: string;
};
// Constants for command display // Constants for command display
const MAX_COMMAND_DISPLAY_LINES = 2; const MAX_COMMAND_DISPLAY_LINES = 2;
const MAX_COMMAND_DISPLAY_CHARS = 160; const MAX_COMMAND_DISPLAY_CHARS = 160;
@ -75,7 +90,7 @@ export function renderToolUseProgressMessage(
); );
} }
const data = lastProgress.data; const data = lastProgress.data as PowerShellProgressData;
return ( return (
<ShellProgressMessage <ShellProgressMessage
@ -115,7 +130,7 @@ export function renderToolResultMessage(
}, },
): React.ReactNode { ): React.ReactNode {
const lastProgress = progressMessagesForMessage.at(-1); const lastProgress = progressMessagesForMessage.at(-1);
const timeoutMs = lastProgress?.data?.timeoutMs; const timeoutMs = (lastProgress?.data as PowerShellProgressData | undefined)?.timeoutMs;
const { stdout, stderr, interrupted, returnCodeInterpretation, isImage, backgroundTaskId } = content; const { stdout, stderr, interrupted, returnCodeInterpretation, isImage, backgroundTaskId } = content;
if (isImage) { if (isImage) {