shreyask Claude Sonnet 4.5 commited on
Commit
4a76a80
·
verified ·
1 Parent(s): 8cb084c

refactor: replace any types with unknown for improved type safety

Browse files

- Replace all any types with unknown in utils.ts and App.tsx
- Update ParsedCall interface, mapArgsToNamedParams, and safeStringifyToolResults
- Fix const usage in JSDoc parsing loop (type, namePart, description)
- Resolve all ESLint @typescript-eslint/no-explicit-any and prefer-const warnings

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>

Files changed (2) hide show
  1. src/App.tsx +1 -1
  2. src/utils.ts +11 -11
src/App.tsx CHANGED
@@ -145,7 +145,7 @@ function renderMarkdown(text: string): string {
145
  return DOMPurify.sanitize(marked.parse(text) as string);
146
  }
147
 
148
- const safeStringifyToolResults = (results: any[]): string => {
149
  try {
150
  const stringified = JSON.stringify(results);
151
  const MAX_SIZE = 5 * 1024 * 1024;
 
145
  return DOMPurify.sanitize(marked.parse(text) as string);
146
  }
147
 
148
+ const safeStringifyToolResults = (results: unknown[]): string => {
149
  try {
150
  const stringified = JSON.stringify(results);
151
  const MAX_SIZE = 5 * 1024 * 1024;
src/utils.ts CHANGED
@@ -1,7 +1,7 @@
1
  interface ParsedCall {
2
  name: string;
3
- positionalArgs: any[];
4
- keywordArgs: Record<string, any>;
5
  }
6
 
7
  interface Schema {
@@ -14,7 +14,7 @@ interface Schema {
14
  {
15
  type: string;
16
  description: string;
17
- default?: any;
18
  }
19
  >;
20
  required: string[];
@@ -110,8 +110,8 @@ export const parsePythonicCalls = (command: string): ParsedCall | null => {
110
 
111
  const [, name, argsStr] = callMatch;
112
  const args = parseArguments(argsStr);
113
- const positionalArgs: any[] = [];
114
- const keywordArgs: Record<string, any> = {};
115
 
116
  for (const arg of args) {
117
  const kwargMatch = arg.match(/^([a-zA-Z0-9_]+)\s*=\s*(.*)$/);
@@ -169,8 +169,8 @@ const extractJSDocParams = (
169
  for (const line of lines) {
170
  const paramMatch = line.match(paramRegex);
171
  if (paramMatch) {
172
- let [, type, namePart, description] = paramMatch;
173
- description = description || "";
174
  let isOptional = false;
175
  let name = namePart;
176
  let jsdocDefault: string | undefined = undefined;
@@ -340,10 +340,10 @@ export const extractToolCallContent = (content: string): string | null => {
340
  */
341
  export const mapArgsToNamedParams = (
342
  paramNames: string[],
343
- positionalArgs: any[],
344
- keywordArgs: Record<string, any>,
345
- ): Record<string, any> => {
346
- const namedParams: Record<string, any> = Object.create(null);
347
  positionalArgs.forEach((arg, idx) => {
348
  if (idx < paramNames.length) {
349
  namedParams[paramNames[idx]] = arg;
 
1
  interface ParsedCall {
2
  name: string;
3
+ positionalArgs: unknown[];
4
+ keywordArgs: Record<string, unknown>;
5
  }
6
 
7
  interface Schema {
 
14
  {
15
  type: string;
16
  description: string;
17
+ default?: unknown;
18
  }
19
  >;
20
  required: string[];
 
110
 
111
  const [, name, argsStr] = callMatch;
112
  const args = parseArguments(argsStr);
113
+ const positionalArgs: unknown[] = [];
114
+ const keywordArgs: Record<string, unknown> = {};
115
 
116
  for (const arg of args) {
117
  const kwargMatch = arg.match(/^([a-zA-Z0-9_]+)\s*=\s*(.*)$/);
 
169
  for (const line of lines) {
170
  const paramMatch = line.match(paramRegex);
171
  if (paramMatch) {
172
+ const [, type, namePart] = paramMatch;
173
+ const description = paramMatch[3] || "";
174
  let isOptional = false;
175
  let name = namePart;
176
  let jsdocDefault: string | undefined = undefined;
 
340
  */
341
  export const mapArgsToNamedParams = (
342
  paramNames: string[],
343
+ positionalArgs: unknown[],
344
+ keywordArgs: Record<string, unknown>,
345
+ ): Record<string, unknown> => {
346
+ const namedParams: Record<string, unknown> = Object.create(null);
347
  positionalArgs.forEach((arg, idx) => {
348
  if (idx < paramNames.length) {
349
  namedParams[paramNames[idx]] = arg;