feat: 完成一大波类型修复, 虽然 any 很多

This commit is contained in:
claude-code-best
2026-03-31 23:43:39 +08:00
parent dd9cd782a7
commit 91f77ea571
55 changed files with 156 additions and 81 deletions

View File

@@ -249,7 +249,7 @@ export function getParentCacheSuppressReason(
// The fork re-processes the parent's output (never cached) plus its own prompt.
const outputTokens = usage.output_tokens ?? 0
return inputTokens + cacheWriteTokens + outputTokens >
return (inputTokens as number) + (cacheWriteTokens as number) + (outputTokens as number) >
MAX_PARENT_UNCACHED_TOKENS
? 'cache_cold'
: null
@@ -344,12 +344,12 @@ export async function generateSuggestion(
if (textBlock?.type === 'text') {
const suggestion = textBlock.text.trim()
if (suggestion) {
return { suggestion, generationRequestId }
return { suggestion: textBlock.text.trim() as string, generationRequestId }
}
}
}
return { suggestion: null, generationRequestId }
return { suggestion: null as string | null, generationRequestId }
}
export function shouldFilterSuggestion(

View File

@@ -673,7 +673,7 @@ export class FirstPartyEventLoggingExporter implements LogRecordExporter {
(attributes.event_name as string) || (log.body as string) || 'unknown'
// Extract metadata objects directly (no JSON parsing needed)
const coreMetadata = attributes.core_metadata as EventMetadata | undefined
const coreMetadata = attributes.core_metadata as unknown as EventMetadata | undefined
const userMetadata = attributes.user_metadata as CoreUserData
const eventMetadata = (attributes.event_metadata || {}) as Record<
string,

View File

@@ -18,7 +18,7 @@ import { getClaudeCodeUserAgent } from '../../utils/userAgent.js'
const bootstrapResponseSchema = lazySchema(() =>
z.object({
client_data: z.record(z.unknown()).nullish(),
client_data: z.record(z.string(), z.unknown()).nullish(),
additional_model_options: z
.array(
z

View File

@@ -1201,7 +1201,7 @@ async function* queryModel(
cachedMCEnabled = featureEnabled && modelSupported
const config = getCachedMCConfig()
logForDebugging(
`Cached MC gate: enabled=${featureEnabled} modelSupported=${modelSupported} model=${options.model} supportedModels=${jsonStringify(config.supportedModels)}`,
`Cached MC gate: enabled=${featureEnabled} modelSupported=${modelSupported} model=${options.model} supportedModels=${jsonStringify((config as any).supportedModels)}`,
)
}
@@ -1704,8 +1704,8 @@ async function* queryModel(
enablePromptCaching,
options.querySource,
useCachedMC,
consumedCacheEdits,
consumedPinnedEdits,
consumedCacheEdits as any,
consumedPinnedEdits as any,
options.skipCacheWrite,
),
system,
@@ -3151,7 +3151,7 @@ export function addCacheBreakpoints(
}
insertBlockAfterToolResults(msg.content, dedupedNewEdits)
// Pin so this block is re-sent at the same position in future calls
pinCacheEdits(i, newCacheEdits)
pinCacheEdits(i, newCacheEdits as any)
logForDebugging(
`Added cache_edits block with ${dedupedNewEdits.edits.length} deletion(s) to message[${i}]: ${dedupedNewEdits.edits.map(e => e.cache_reference).join(', ')}`,

View File

@@ -107,7 +107,7 @@ async function retryWithBackoff<T>(
return result.value
}
lastError = result.error || `${operation} failed`
lastError = (result as any).error || `${operation} failed`
logDebug(
`${operation} attempt ${attempt}/${MAX_RETRIES} failed: ${lastError}`,
)

View File

@@ -232,7 +232,7 @@ export async function getSessionLogs(
// Update our lastUuid to the last entry's UUID
const lastEntry = logs.at(-1)
if (lastEntry && 'uuid' in lastEntry && lastEntry.uuid) {
lastUuidMap.set(sessionId, lastEntry.uuid)
lastUuidMap.set(sessionId, lastEntry.uuid as string)
}
}

View File

@@ -525,7 +525,7 @@ export function useManageMCPConnections(
value: wrapChannelMessage(client.name, content, meta),
priority: 'next',
isMeta: true,
origin: { kind: 'channel', server: client.name },
origin: { kind: 'channel', server: client.name } as any,
skipSlashCommands: true,
})
},

View File

@@ -136,7 +136,7 @@ async function isAppleTerminalBellDisabled(): Promise<boolean> {
// Lazy-load plist (~280KB with xmlbuilder+@xmldom) — only hit on
// Apple_Terminal with auto-channel, which is a small fraction of users.
const plist = await import('plist')
const parsed: Record<string, unknown> = plist.parse(defaultsOutput.stdout)
const parsed: Record<string, unknown> = plist.parse(defaultsOutput.stdout) as any
const windowSettings = parsed?.['Window Settings'] as
| Record<string, unknown>
| undefined

View File

@@ -411,7 +411,7 @@ function roughTokenCountEstimationForBlock(
return 2000
}
if (block.type === 'tool_result') {
return roughTokenCountEstimationForContent(block.content)
return roughTokenCountEstimationForContent(block.content as any)
}
if (block.type === 'tool_use') {
// input is the JSON the model generated — arbitrarily large (bash