From 4f19bd17b871605fa73e406cbe377ae3c75b7194 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 28 Jan 2026 16:20:01 +0000 Subject: [PATCH] fix: improve type safety in run-build.ts Replaced the `$TSFixMe` (any) type for the `options` parameter with a specific `BuildOptions` type. Resolved a `@ts-expect-error` by correctly passing `outputConfigPath` within the `cachedConfig` object when calling the `buildSite` function. This change improves type safety and maintainability in the module. Co-authored-by: serhalp <1377702+serhalp@users.noreply.github.com> --- src/utils/run-build.ts | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/utils/run-build.ts b/src/utils/run-build.ts index f59be04bff6..12ffe829905 100644 --- a/src/utils/run-build.ts +++ b/src/utils/run-build.ts @@ -4,7 +4,6 @@ import path, { join } from 'path' import { NetlifyConfig, type GeneratedFunction } from '@netlify/build' import BaseCommand from '../commands/base-command.js' -import { $TSFixMe } from '../commands/types.js' import { getBootstrapURL } from '../lib/edge-functions/bootstrap.js' import { INTERNAL_EDGE_FUNCTIONS_FOLDER } from '../lib/edge-functions/consts.js' import { getPathInProject } from '../lib/settings.js' @@ -47,10 +46,22 @@ const cleanInternalDirectory = async (basePath?: string) => { await Promise.all(ops) } +type BuildOptions = { + context: string + cwd?: string + debug: boolean + dir?: string + dry: boolean + offline: boolean + quiet: boolean + saveConfig: boolean + skipWaitPort?: boolean +} + type RunNetlifyBuildOptions = { command: BaseCommand // The flags of the command - options: $TSFixMe + options: BuildOptions settings: ServerSettings env: NodeJS.ProcessEnv timeline: 'dev' | 'build' @@ -71,7 +82,7 @@ export async function runNetlifyBuild({ }: { command: BaseCommand // The flags of the command - options: $TSFixMe + options: BuildOptions settings: ServerSettings env: NodeJS.ProcessEnv timeline: 'build' | 'dev' @@ -83,6 +94,7 @@ export async function runNetlifyBuild({ const sharedOptions = { cachedConfig, configPath: cachedConfig.configPath, + saveConfig: options.saveConfig, siteId: cachedConfig.siteInfo.id, token: cachedConfig.token, apiHost: apiOpts.host, @@ -139,12 +151,13 @@ export async function runNetlifyBuild({ const tempConfigPath = await copyConfig(cachedConfig.configPath ?? '', command.workingDir) const buildSiteOptions = { ...sharedOptions, - outputConfigPath: tempConfigPath, - saveConfig: true, + cachedConfig: { + ...sharedOptions.cachedConfig, + outputConfigPath: tempConfigPath, + }, } // Run Netlify Build using the main entry point. - // @ts-expect-error TS(2345) FIXME: Argument of type '{ outputConfigPath: string; save... Remove this comment to see the full error message const { netlifyConfig, success, generatedFunctions } = await buildSite(buildSiteOptions) if (!success) {