-
Notifications
You must be signed in to change notification settings - Fork 131
Description
Summary
The TypeScript SDK has 28 as any type suppressions across 4 core source files. These bypass TypeScript's type system, hide potential bugs, and make refactoring unsafe.
Current State
Agent.ts — 20 instances (worst offender)
camelCase ↔ snake_case execution context mapping (L814-839):
executionId: (ctx as any).executionId ?? ctx.execution_id ?? ctx.executionId,
runId: ctx.runId ?? (ctx as any).run_id,
workflowId: ctx.workflowId ?? (ctx as any).workflow_id,
parentExecutionId: ctx.parentExecutionId ?? (ctx as any).parent_execution_id,
sessionId: ctx.sessionId ?? (ctx as any).session_id,
actorId: ctx.actorId ?? (ctx as any).actor_id,
callerDid: (ctx as any).callerDid ?? (ctx as any).caller_did,
targetDid: (ctx as any).targetDid ?? (ctx as any).target_did,
agentNodeDid: (ctx as any).agentNodeDid ?? (ctx as any).agent_node_didFix: Create a RawExecutionContext type that accepts both camelCase and snake_case fields, then add a normalizeExecutionContext() utility function.
Express routing (L608, 611, 740):
this.app.post('/api/v1/reasoners/*', (req, res) => this.executeReasoner(req, res, (req.params as any)[0]));
handler(req as any, res as any);Fix: Use proper Express ParamsDictionary types or declare route parameter types.
Parsed body access (L925-929):
if ((parsed as any).input !== undefined) { return (parsed as any).input; }
if ((parsed as any).data !== undefined) { return (parsed as any).data; }Fix: Define ParsedBody interface with optional input and data fields.
AgentFieldClient.ts — 4 instances
// L117-118: Status enrichment
(enriched as any).status = status;
(enriched as any).responseData = respData;
// L252, 259: Discovery response mapping
compact: this.mapCompactDiscovery(parsed as any)
json: this.mapDiscoveryResponse(parsed as any)Fix: Define proper intermediate types for enriched responses and parsed discovery payloads.
RateLimiter.ts — 2 instances
// L60, 101
const err = error as any;Fix: Use error instanceof Error narrowing or a toError() utility.
ToolCalling.ts — 2 instances
// L371, 446
const originalTool = t as any;
const orig = t as any;Fix: These access .description and .inputSchema on Vercel AI SDK tool() return values. The AI SDK types don't expose these properties. Either use Parameters<typeof tool>[0] to type the config, or extract the config before creating the tool.
Acceptance Criteria
- No
as anytypes remain inAgent.ts - No
as anytypes remain inAgentFieldClient.ts - No
as anytypes remain inRateLimiter.ts - No
as anytypes remain inToolCalling.ts - TypeScript compilation passes without errors
- All existing tests pass
- No
@ts-ignoreor@ts-expect-errorintroduced as replacements
Files
sdk/typescript/src/agent/Agent.ts(20 instances)sdk/typescript/src/client/AgentFieldClient.ts(4 instances)sdk/typescript/src/ai/RateLimiter.ts(2 instances)sdk/typescript/src/ai/ToolCalling.ts(2 instances)
Related Issues
- [Web UI] Replace any types in ExecutionForm.tsx #105 — Same pattern but for Web UI TSX (1 file)
- feat: abstract SDK-injected prompt text into a configurable PromptTemplates layer #229 — PromptTemplates refactor will touch
ToolCalling.ts - [TypeScript SDK] Align memory scope naming with Python SDK #93 — TS SDK parity with Python SDK
Using AI to solve this issue? Read our AI-Assisted Contributions guide for testing requirements, prompt strategies, and common pitfalls to avoid.