From 4c70352ace61036a5889b33ed3d366fa3d737e51 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 17 Mar 2026 16:38:47 +0000 Subject: [PATCH] refactor: use explicit CliOptions type instead of any in CLI handlers Defined a CliOptions interface in src/cli/index.ts to improve type safety and maintainability. Replaced the use of 'any' in handleSimpleFetch and handleTypeGeneration with the new interface. Updated runCli to use CliOptions for its local options object. Co-authored-by: sebamar88 <4359231+sebamar88@users.noreply.github.com> --- src/cli/index.ts | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/cli/index.ts b/src/cli/index.ts index 9010526..e100139 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -6,6 +6,15 @@ import { generateFromSwagger } from "./swagger-generator.js"; type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE"; +interface CliOptions { + type?: boolean; + swagger?: boolean; + method: HttpMethod; + body?: string; + url?: string; + headers: Record; +} + /** * Main CLI entry point for bytekit */ @@ -15,14 +24,7 @@ export async function runCli(argv: string[]): Promise { return; } - const options: { - type?: boolean; - swagger?: boolean; - method: HttpMethod; - body?: string; - url?: string; - headers: Record; - } = { + const options: CliOptions = { method: "GET", headers: {}, }; @@ -82,7 +84,9 @@ export async function runCli(argv: string[]): Promise { } } -async function handleTypeGeneration(options: any): Promise { +async function handleTypeGeneration( + options: CliOptions & { url: string } +): Promise { const url = new URL(options.url); const endpointName = url.pathname.split("/").filter(Boolean).pop() || "api"; @@ -104,7 +108,9 @@ async function handleTypeGeneration(options: any): Promise { }); } -async function handleSimpleFetch(options: any): Promise { +async function handleSimpleFetch( + options: CliOptions & { url: string } +): Promise { console.log(`\n📡 Fetching ${options.method} ${options.url}...`); try { const response = await fetch(options.url, {