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 1/2] 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, { From 040d9e688cf70462f13a0e05583dd5d8f418418a Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 18 Mar 2026 12:31:21 +0000 Subject: [PATCH 2/2] refactor: use explicit CliOptions type and fix CI type errors 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. Added type assertions when calling these handlers to satisfy the TypeScript compiler that the URL is present after the explicit check. Co-authored-by: sebamar88 <4359231+sebamar88@users.noreply.github.com> --- src/cli/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cli/index.ts b/src/cli/index.ts index e100139..72525d3 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -77,10 +77,10 @@ export async function runCli(argv: string[]): Promise { if (options.swagger) { await generateFromSwagger({ url: options.url }); } else if (options.type) { - await handleTypeGeneration(options); + await handleTypeGeneration(options as CliOptions & { url: string }); } else { // Simple fetch/curl behavior if --type is not present - await handleSimpleFetch(options); + await handleSimpleFetch(options as CliOptions & { url: string }); } }