8.2 KiB
Plan Only: Anthropic-Core as any Type Safety Improvement
IMPORTANT
- DO NOT execute any code changes. Produce a detailed plan ONLY.
- Output your plan to
docs/plans/as-any-cleanup.mdin the repo. - For each of the 94
as any, classify as: (FIXABLE with concrete type fix), (JUSTIFIED — explain why), or (NEEDS_UPSTREAM — requires CCB upstream context)
Goal
Eliminate all fixable as any casts in Anthropic-original decompiled code, improving type safety and reducing technical debt. These are all decompilation artifacts — the original Anthropic TypeScript had proper types that were lost in decompilation.
Scope
94 as any across ~60 files. EXCLUDED areas: API providers (openai/grok/gemini — JSON parsing), community commands (acp/autofix-pr/share/issue), generated types, test files, .d.ts stubs.
Full List of as any by File
src/main.tsx
- L408:
(global as any).require('inspector')
src/hooks/
- useIdeSelection.ts L113:
SelectionChangedSchema() as any - useVirtualScroll.ts L186: comment only (not actual as any)
- toolPermission/PermissionContext.ts L228:
suggestions as any - useIdeLogging.ts L30:
LogEventSchema() as any - usePromptsFromClaudeInChrome.tsx L51:
ClaudeInChromePromptNotificationSchema() as any
src/components/
- FeedbackSurvey/useFrustrationDetection.ts L15:
(m as any).isApiErrorMessage - FeedbackSurvey/useFrustrationDetection.ts L28:
isPolicyAllowed('product_feedback' as any) - ultraplan/UltraplanChoiceDialog.tsx L97:
(key as any).wheelDown - ultraplan/UltraplanChoiceDialog.tsx L98:
(key as any).wheelDown - ultraplan/UltraplanChoiceDialog.tsx L100:
(key as any).wheelUp - ultraplan/UltraplanChoiceDialog.tsx L101:
(key as any).wheelUp - PromptInput/PromptInput.tsx L1802:
mode: previousModeBeforeAuto as any - PromptInput/PromptInput.tsx L1808:
mode: previousModeBeforeAuto as any - messages/AttachmentMessage.tsx L146:
attachment as any - messages/UserTextMessage.tsx L106:
UserGitHubWebhookMessage as any - messages/UserTextMessage.tsx L160:
UserForkBoilerplateMessage as any - messages/UserTextMessage.tsx L173:
UserCrossSessionMessage as any - ConsoleOAuthFlow.tsx L275:
{ modelType: 'anthropic' } as any - ConsoleOAuthFlow.tsx L680:
modelType: 'anthropic' as any - ConsoleOAuthFlow.tsx L682:
} as any - ConsoleOAuthFlow.tsx L900:
modelType: 'openai' as any - ConsoleOAuthFlow.tsx L902:
} as any - ConsoleOAuthFlow.tsx L1133:
modelType: 'gemini' as any - ConsoleOAuthFlow.tsx L1135:
} as any - permissions/PermissionRequest.tsx L106:
(MonitorPermissionRequest ?? FallbackPermissionRequest) as any
src/utils/
- sideQuery.ts L224:
client.chat.completions.create(requestParams as any, ...) - execFileNoThrowPortable.ts L75:
(execaSync as any)(command, ...) - ultraplan/ccrSession.ts L104:
(m as any).message.content - ultraplan/ccrSession.ts L112:
(m as any).message.content - transcriptSearch.ts L100:
(p as any[]) - filePersistence/outputsScanner.ts L72:
}) as any[] - filePersistence/outputsScanner.ts L116:
(turnStartTime as any as number) - performanceShim.ts L140:
markResourceTiming: (() => {}) as any - performanceShim.ts L146:
(original as any).onresourcetimingbufferfull - performanceShim.ts L162:
(globalThis as any).__performanceShimInstalled - performanceShim.ts L163:
(globalThis as any).__performanceShimInstalled = true - settings/validateEditTool.ts L39:
(afterValidation as any).error - log.ts L233:
(await readdir(...)) as any - hooks/execAgentHook.ts L214:
(message as any).attachment.type - hooks/execAgentHook.ts L216:
(message as any).attachment.data - computerUse/escHotkey.ts L29:
(cu as any).hotkey?.registerEscape - computerUse/escHotkey.ts L44:
(requireComputerUseSwift() as any).hotkey?.unregister() - computerUse/escHotkey.ts L54:
(requireComputerUseSwift() as any).hotkey?.notifyExpectedEscape() - computerUse/hostAdapter.ts L83:
(cu as any).tcc - computerUse/executorCrossPlatform.ts L494:
(this as any).mouseDown() - computerUse/executorCrossPlatform.ts L499:
(this as any).mouseUp() - computerUse/executorCrossPlatform.ts L556:
windowManagement.manageWindow(action as any, opts) - computerUse/win32/bridgeClient.ts L136:
(writable as any).flush - computerUse/win32/bridgeClient.ts L137:
(writable as any).flush() - computerUse/drainRunLoop.ts L21:
(cu as any)?._drainMainRunLoop?.() - computerUse/common.ts L57:
: 'none') as any - computerUse/common.ts L62:
: 'darwin') as any - messageQueueManager.ts L371:
(cmd as any).origin?.kind === 'channel' - plugins/marketplaceManager.ts L191:
} as any - forkedAgent.ts L565:
(message as any).event?.type === 'message_delta' - forkedAgent.ts L566:
(message as any).event.usage - forkedAgent.ts L568:
(message as any).event.usage - deepLink/protocolHandler.ts L97:
(waitForUrlEvent as any)(5000) - sliceAnsi.ts L80:
(token as any).value - plans.ts L370:
(snapshotFiles as any[]) - plans.ts L377:
(snapshotFiles as any[]) - textHighlighting.ts L131:
(token as any).value.length - textHighlighting.ts L138:
(token as any).value.length - sideQuestion.ts L139:
(toolUse as any).name - sideQuestion.ts L151:
formatAPIError(apiErr.error as any) - messages.ts L3894:
attachment as any - searchExtraTools.ts L507:
(msg as any).compactMetadata?.preCompactDiscoveredTools - effort.ts L81:
get3PModelCapabilityOverride(_model, 'xhigh_effort' as any) - sessionRestore.ts L81:
(msg.message!.content as any[]) - worktree.ts L1296:
(result as any).baseBranch - permissions/permissions.ts L416:
suggestions as any - permissions/permissions.ts L427:
decision.updatedPermissions as any - permissions/permissions.ts L432:
decision.updatedPermissions as any - auth.ts L120:
(settings as any).modelType === 'openai' - auth.ts L121:
(settings as any).modelType === 'gemini' - swarm/inProcessRunner.ts L1452:
(m.message?.content ?? []) as any[]
src/constants/
- promptEngineeringAudit.runner.ts L15:
(globalThis as any).MACRO = { - promptEngineeringAudit.runner.ts L217:
] as any - outputStyles.ts L188:
(style as any).source === 'plugin' - outputStyles.ts L189:
(style as any).forceForPlugin === true
src/services/
- vcr.ts L272:
.filter(Boolean) as any - tokenEstimation.ts L482:
block.content as any - skillSearch/prefetch.ts L244:
} as any - skillSearch/prefetch.ts L309:
} as any - notifier.ts L139:
plist.parse(defaultsOutput.stdout) as any
src/tasks/
- LocalShellTask/killShellTasks.ts L18:
(task as any).status !== 'running'
src/buddy/
- companionReact.ts L76:
(m as any).message?.content - companionReact.ts L92:
(m as any).message?.content
src/entrypoints/
- mcp.ts L147:
(validationResult as any).message - cli.tsx L13:
(globalThis as any).MACRO = { - cli.tsx L149:
ChannelPermissionRequestNotificationSchema() as any
packages/builtin-tools/src/tools/
- FileReadTool/FileReadTool.ts L913,917,984,1000,1177 (5 total):
(extractResult as any),(sharp as any) - AgentTool/runAgent.ts L789-808 (5 total):
(message as any).event,(message as any).ttftMs, etc.
Categories for Analysis
For each occurrence, classify and recommend:
A. Zod schemas (2,5,6,92): SomeSchema() as any — schema type inference lost
B. Message/attachment access (7,29-31,40-41,56-58,67-68,70,77,88-89): accessing sub-properties not in SDKMessage type
C. globalThis/global MACRO (1,13-14,36-37,78,91): dev-mode constants injected at build time
D. ComputerUse dynamic modules (42-53): optional native module feature detection
E. ConsoleOAuthFlow config (19-25): settings update type mismatches
F. Theme/permission/config (4,72-74,75-76,80-81): style/permission type extensions
G. CLI key handlers (9-12): non-standard KeyboardEvent properties
H. Performance polyfill (34-37): Bun lacks browser performance API
I. Dynamic function calls (27-28,59): execaSync, openai client calls, dynamic imports
J. Misc runtime access (3,8,15-18,26,32-33,38-39,54-55,60-66,69,71,79,82-87,90,93-94)
Verification
After plan is complete, verify by running:
export PATH="$HOME/.bun/bin:$PATH"
bun run typecheck # should still have 20 errors (community code, unchanged)