diff --git a/src/commands/dev/dev.ts b/src/commands/dev/dev.ts index c37d4686727..57d652d3c64 100644 --- a/src/commands/dev/dev.ts +++ b/src/commands/dev/dev.ts @@ -92,7 +92,7 @@ export const dev = async (options: OptionValues, command: BaseCommand) => { const { api, cachedConfig, config, repositoryRoot, site, siteInfo, state } = command.netlify config.dev = { ...config.dev } config.build = { ...config.build } - const devConfig = { + const devConfig: DevConfig = { framework: '#auto', autoLaunch: Boolean(options.open), ...(cachedConfig.siteInfo?.dev_server_settings && { @@ -104,7 +104,7 @@ export const dev = async (options: OptionValues, command: BaseCommand) => { ...(config.build.base && { base: config.build.base }), ...config.dev, ...options, - } as DevConfig + } let { env } = cachedConfig diff --git a/src/commands/dev/types.d.ts b/src/commands/dev/types.d.ts index 8de81b1193f..54b5ac6a15d 100644 --- a/src/commands/dev/types.d.ts +++ b/src/commands/dev/types.d.ts @@ -1,4 +1,4 @@ -import type { PollingStrategy, NetlifyTOML } from '@netlify/build-info' +import type { NetlifyTOML } from '@netlify/build-info' import type { FrameworkNames } from '../../utils/types' @@ -8,23 +8,14 @@ export type BuildConfig = NonNullable export type DevConfig = NonNullable & { framework: FrameworkNames /** Directory of the functions */ - functions?: string - publish?: string - /** Port to serve the functions */ - port: number - live: boolean + functions?: string | undefined + live?: boolean | undefined /** The base directory from the [build] section of the configuration file */ - base?: string - staticServerPort?: number - functionsPort?: number - autoLaunch?: boolean - https?: { - keyFile: string - certFile: string - } - envFiles?: string[] + base?: string | undefined + staticServerPort?: number | undefined + envFiles?: string[] | undefined - jwtSecret: string - jwtRolePath: string - pollingStrategies?: PollingStrategy[] + jwtSecret?: string | undefined + jwtRolePath?: string | undefined + pollingStrategies?: string[] | undefined } diff --git a/src/commands/serve/serve.ts b/src/commands/serve/serve.ts index 6c63f3ef911..3b398d4c25b 100644 --- a/src/commands/serve/serve.ts +++ b/src/commands/serve/serve.ts @@ -37,7 +37,7 @@ export const serve = async (options: OptionValues, command: BaseCommand) => { const { api, cachedConfig, config, frameworksAPIPaths, repositoryRoot, site, siteInfo, state } = command.netlify config.dev = { ...config.dev } config.build = { ...config.build } - const devConfig = { + const devConfig: DevConfig = { ...(config.functionsDirectory && { functions: config.functionsDirectory }), ...(config.build.publish && { publish: config.build.publish }), @@ -46,7 +46,7 @@ export const serve = async (options: OptionValues, command: BaseCommand) => { // Override the `framework` value so that we start a static server and not // the framework's development server. framework: '#static', - } as DevConfig + } let { env } = cachedConfig diff --git a/src/utils/detect-server-settings.ts b/src/utils/detect-server-settings.ts index 30ecf16ee89..b5e4e8b2f47 100644 --- a/src/utils/detect-server-settings.ts +++ b/src/utils/detect-server-settings.ts @@ -193,7 +193,7 @@ const handleCustomFramework = ({ frameworkPort: devConfig.targetPort, dist: devConfig.publish || getDefaultDist(workingDir), framework: '#custom', - pollingStrategies: devConfig.pollingStrategies?.map((s) => s.name) ?? [], + pollingStrategies: devConfig.pollingStrategies ?? [], } } diff --git a/src/utils/types.ts b/src/utils/types.ts index 27fddc0eead..65603b59dc1 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -1,7 +1,8 @@ -import { Buffer } from 'buffer' -import { IncomingMessage } from 'http' +import type { Buffer } from 'buffer' +import type { IncomingMessage } from 'http' -import { Match } from 'netlify-redirector' +import type { PollingStrategy, Settings } from '@netlify/build-info' +import type { Match } from 'netlify-redirector' export type FrameworkNames = '#static' | '#auto' | '#custom' | string @@ -12,7 +13,7 @@ export type FrameworkInfo = { dev: { commands: string[] port: number - pollingStrategies: { name: string }[] + pollingStrategies: PollingStrategy[] } name: FrameworkNames staticAssetsDirectory: string