Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/commands/dev/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 && {
Expand All @@ -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

Expand Down
27 changes: 9 additions & 18 deletions src/commands/dev/types.d.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -8,23 +8,14 @@ export type BuildConfig = NonNullable<NetlifyTOML['build']>
export type DevConfig = NonNullable<NetlifyTOML['dev']> & {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can see here we're extending this type, but we were duplicating most of it here. Most of this diff is cleaning up this unnecessary duplication + adding undefined to optional properties.

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[]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jwtSecret?: string | undefined
jwtRolePath?: string | undefined
pollingStrategies?: string[] | undefined
}
4 changes: 2 additions & 2 deletions src/commands/serve/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }),

Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/utils/detect-server-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?? [],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the regression/fix

}
}

Expand Down
9 changes: 5 additions & 4 deletions src/utils/types.ts
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -12,7 +13,7 @@ export type FrameworkInfo = {
dev: {
commands: string[]
port: number
pollingStrategies: { name: string }[]
pollingStrategies: PollingStrategy[]
Comment on lines -15 to +16
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one was correct. I made it reference the canonical type while I was here.

}
name: FrameworkNames
staticAssetsDirectory: string
Expand Down
Loading