Skip to content

refactor: cherry-pick type fixes from #7058 and #7068 #7383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
22 changes: 10 additions & 12 deletions src/commands/deploy/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,20 +228,14 @@
return { deployFolderStat, functionsFolderStat }
}

/**
* @param {object} config
* @param {string} config.deployFolder
* @param {*} config.site
* @returns
*/
// @ts-expect-error TS(7031) FIXME: Binding element 'deployFolder' implicitly has an '... Remove this comment to see the full error message
const getDeployFilesFilter = ({ deployFolder, site }) => {
const getDeployFilesFilter = ({ deployFolder, site }: { deployFolder: string; site: { root: string } }) => {
// site.root === deployFolder can happen when users run `netlify deploy --dir .`
// in that specific case we don't want to publish the repo node_modules
// when site.root !== deployFolder the behaviour matches our buildbot
const skipNodeModules = site.root === deployFolder

return (filename: string) => {
// TODO(serhalp) Per types, this should not be possible. Confirm and remove this check.
if (filename == null) {
return false
}
Expand Down Expand Up @@ -285,21 +279,25 @@
}
}

// @ts-expect-error TS(7006) FIXME: Parameter 'actual' implicitly has an 'any' type.
const hasErrorMessage = (actual, expected) => {
const hasErrorMessage = (actual: unknown, expected: string): boolean => {
if (typeof actual === 'string') {
return actual.includes(expected)
}
return false
}

// @ts-expect-error TS(7031) FIXME: Binding element 'error_' implicitly has an 'any' t... Remove this comment to see the full error message
const reportDeployError = ({ error_, failAndExit }) => {
const reportDeployError = ({
error_,
failAndExit,
}: {
error_: (Error & { json?: Record<string, unknown>; status?: number }) | any

Check failure on line 293 in src/commands/deploy/deploy.ts

View workflow job for this annotation

GitHub Actions / Lint

'any' overrides all other types in this union type

Check failure on line 293 in src/commands/deploy/deploy.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
failAndExit: (errorOrMessage: Error | string) => void
}) => {
switch (true) {
case error_.name === 'JSONHTTPError': {
const message = error_?.json?.message ?? ''
if (hasErrorMessage(message, 'Background Functions not allowed by team plan')) {
return failAndExit(`\n${BACKGROUND_FUNCTIONS_WARNING}`)

Check failure on line 300 in src/commands/deploy/deploy.ts

View workflow job for this annotation

GitHub Actions / Lint

Returning a void expression from a function is forbidden. Please move it before the `return` statement
}
warn(`JSONHTTPError: ${message} ${error_.status}`)
warn(`\n${JSON.stringify(error_, null, ' ')}\n`)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/functions/functions-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@
env: command.netlify.cachedConfig.env,
site: command.netlify.site,
})
injectEnvVariables(env)

Check failure on line 610 in src/commands/functions/functions-create.ts

View workflow job for this annotation

GitHub Actions / typecheck

Argument of type 'Record<string, { sources: string[]; value: string; }>' is not assignable to parameter of type 'EnvironmentVariables'.

Check failure on line 610 in src/commands/functions/functions-create.ts

View workflow job for this annotation

GitHub Actions / Unit (ubuntu-latest, 20.12.2)

Argument of type 'Record<string, { sources: string[]; value: string; }>' is not assignable to parameter of type 'EnvironmentVariables'.

Check failure on line 610 in src/commands/functions/functions-create.ts

View workflow job for this annotation

GitHub Actions / Unit (macOS-latest, 20.12.2)

Argument of type 'Record<string, { sources: string[]; value: string; }>' is not assignable to parameter of type 'EnvironmentVariables'.

Check failure on line 610 in src/commands/functions/functions-create.ts

View workflow job for this annotation

GitHub Actions / Unit (macOS-latest, 22.x)

Argument of type 'Record<string, { sources: string[]; value: string; }>' is not assignable to parameter of type 'EnvironmentVariables'.

Check failure on line 610 in src/commands/functions/functions-create.ts

View workflow job for this annotation

GitHub Actions / Unit (ubuntu-latest, 22.x)

Argument of type 'Record<string, { sources: string[]; value: string; }>' is not assignable to parameter of type 'EnvironmentVariables'.

Check failure on line 610 in src/commands/functions/functions-create.ts

View workflow job for this annotation

GitHub Actions / Integration (ubuntu-latest, 20.12.2, 1/4)

Argument of type 'Record<string, { sources: string[]; value: string; }>' is not assignable to parameter of type 'EnvironmentVariables'.

Check failure on line 610 in src/commands/functions/functions-create.ts

View workflow job for this annotation

GitHub Actions / E2E (macOS-latest, 22)

Argument of type 'Record<string, { sources: string[]; value: string; }>' is not assignable to parameter of type 'EnvironmentVariables'.

Check failure on line 610 in src/commands/functions/functions-create.ts

View workflow job for this annotation

GitHub Actions / Integration (ubuntu-latest, 22, 2/4)

Argument of type 'Record<string, { sources: string[]; value: string; }>' is not assignable to parameter of type 'EnvironmentVariables'.

Check failure on line 610 in src/commands/functions/functions-create.ts

View workflow job for this annotation

GitHub Actions / Integration (macOS-latest, 20.12.2, 4/4)

Argument of type 'Record<string, { sources: string[]; value: string; }>' is not assignable to parameter of type 'EnvironmentVariables'.

Check failure on line 610 in src/commands/functions/functions-create.ts

View workflow job for this annotation

GitHub Actions / E2E (ubuntu-latest, 22)

Argument of type 'Record<string, { sources: string[]; value: string; }>' is not assignable to parameter of type 'EnvironmentVariables'.

Check failure on line 610 in src/commands/functions/functions-create.ts

View workflow job for this annotation

GitHub Actions / Integration (macOS-latest, 22, 3/4)

Argument of type 'Record<string, { sources: string[]; value: string; }>' is not assignable to parameter of type 'EnvironmentVariables'.

Check failure on line 610 in src/commands/functions/functions-create.ts

View workflow job for this annotation

GitHub Actions / Integration (ubuntu-latest, 22, 3/4)

Argument of type 'Record<string, { sources: string[]; value: string; }>' is not assignable to parameter of type 'EnvironmentVariables'.

Check failure on line 610 in src/commands/functions/functions-create.ts

View workflow job for this annotation

GitHub Actions / Integration (macOS-latest, 22, 4/4)

Argument of type 'Record<string, { sources: string[]; value: string; }>' is not assignable to parameter of type 'EnvironmentVariables'.

Check failure on line 610 in src/commands/functions/functions-create.ts

View workflow job for this annotation

GitHub Actions / E2E (ubuntu-latest, 20.12.2)

Argument of type 'Record<string, { sources: string[]; value: string; }>' is not assignable to parameter of type 'EnvironmentVariables'.

Check failure on line 610 in src/commands/functions/functions-create.ts

View workflow job for this annotation

GitHub Actions / Integration (ubuntu-latest, 20.12.2, 4/4)

Argument of type 'Record<string, { sources: string[]; value: string; }>' is not assignable to parameter of type 'EnvironmentVariables'.

Check failure on line 610 in src/commands/functions/functions-create.ts

View workflow job for this annotation

GitHub Actions / Integration (ubuntu-latest, 22, 4/4)

Argument of type 'Record<string, { sources: string[]; value: string; }>' is not assignable to parameter of type 'EnvironmentVariables'.

Check failure on line 610 in src/commands/functions/functions-create.ts

View workflow job for this annotation

GitHub Actions / Integration (ubuntu-latest, 20.12.2, 3/4)

Argument of type 'Record<string, { sources: string[]; value: string; }>' is not assignable to parameter of type 'EnvironmentVariables'.

Check failure on line 610 in src/commands/functions/functions-create.ts

View workflow job for this annotation

GitHub Actions / Integration (ubuntu-latest, 22, 1/4)

Argument of type 'Record<string, { sources: string[]; value: string; }>' is not assignable to parameter of type 'EnvironmentVariables'.

Check failure on line 610 in src/commands/functions/functions-create.ts

View workflow job for this annotation

GitHub Actions / E2E (macOS-latest, 20.12.2)

Argument of type 'Record<string, { sources: string[]; value: string; }>' is not assignable to parameter of type 'EnvironmentVariables'.

Check failure on line 610 in src/commands/functions/functions-create.ts

View workflow job for this annotation

GitHub Actions / Integration (macOS-latest, 20.12.2, 1/4)

Argument of type 'Record<string, { sources: string[]; value: string; }>' is not assignable to parameter of type 'EnvironmentVariables'.

Check failure on line 610 in src/commands/functions/functions-create.ts

View workflow job for this annotation

GitHub Actions / Integration (macOS-latest, 22, 1/4)

Argument of type 'Record<string, { sources: string[]; value: string; }>' is not assignable to parameter of type 'EnvironmentVariables'.

Check failure on line 610 in src/commands/functions/functions-create.ts

View workflow job for this annotation

GitHub Actions / Integration (macOS-latest, 22, 2/4)

Argument of type 'Record<string, { sources: string[]; value: string; }>' is not assignable to parameter of type 'EnvironmentVariables'.

Check failure on line 610 in src/commands/functions/functions-create.ts

View workflow job for this annotation

GitHub Actions / Integration (macOS-latest, 20.12.2, 2/4)

Argument of type 'Record<string, { sources: string[]; value: string; }>' is not assignable to parameter of type 'EnvironmentVariables'.

Check failure on line 610 in src/commands/functions/functions-create.ts

View workflow job for this annotation

GitHub Actions / Integration (ubuntu-latest, 20.12.2, 2/4)

Argument of type 'Record<string, { sources: string[]; value: string; }>' is not assignable to parameter of type 'EnvironmentVariables'.

Check failure on line 610 in src/commands/functions/functions-create.ts

View workflow job for this annotation

GitHub Actions / Integration (macOS-latest, 20.12.2, 3/4)

Argument of type 'Record<string, { sources: string[]; value: string; }>' is not assignable to parameter of type 'EnvironmentVariables'.

Check failure on line 610 in src/commands/functions/functions-create.ts

View workflow job for this annotation

GitHub Actions / Integration (windows-2025, 20.12.2, 3/4)

Argument of type 'Record<string, { sources: string[]; value: string; }>' is not assignable to parameter of type 'EnvironmentVariables'.

Check failure on line 610 in src/commands/functions/functions-create.ts

View workflow job for this annotation

GitHub Actions / Unit (windows-2025, 20.12.2)

Argument of type 'Record<string, { sources: string[]; value: string; }>' is not assignable to parameter of type 'EnvironmentVariables'.

Check failure on line 610 in src/commands/functions/functions-create.ts

View workflow job for this annotation

GitHub Actions / E2E Windows tests (windows-2025, 22)

Argument of type 'Record<string, { sources: string[]; value: string; }>' is not assignable to parameter of type 'EnvironmentVariables'.

Check failure on line 610 in src/commands/functions/functions-create.ts

View workflow job for this annotation

GitHub Actions / Integration (windows-2025, 20.12.2, 1/4)

Argument of type 'Record<string, { sources: string[]; value: string; }>' is not assignable to parameter of type 'EnvironmentVariables'.

Check failure on line 610 in src/commands/functions/functions-create.ts

View workflow job for this annotation

GitHub Actions / Integration test windows latest node23 specific

Argument of type 'Record<string, { sources: string[]; value: string; }>' is not assignable to parameter of type 'EnvironmentVariables'.

Check failure on line 610 in src/commands/functions/functions-create.ts

View workflow job for this annotation

GitHub Actions / E2E Windows tests (windows-2025, 20.12.2)

Argument of type 'Record<string, { sources: string[]; value: string; }>' is not assignable to parameter of type 'EnvironmentVariables'.

Check failure on line 610 in src/commands/functions/functions-create.ts

View workflow job for this annotation

GitHub Actions / Integration (windows-2025, 20.12.2, 2/4)

Argument of type 'Record<string, { sources: string[]; value: string; }>' is not assignable to parameter of type 'EnvironmentVariables'.

Check failure on line 610 in src/commands/functions/functions-create.ts

View workflow job for this annotation

GitHub Actions / Integration (windows-2025, 20.12.2, 4/4)

Argument of type 'Record<string, { sources: string[]; value: string; }>' is not assignable to parameter of type 'EnvironmentVariables'.
await onComplete.call(command)
}
}
Expand Down Expand Up @@ -640,7 +640,7 @@
return
}

await injectEnvVariables({
injectEnvVariables({
devConfig: { ...config.dev },
env: command.netlify.cachedConfig.env,
site: command.netlify.site,
Expand Down
2 changes: 1 addition & 1 deletion src/commands/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type NetlifySite = {
configPath?: string
siteId?: string
get id(): string | undefined
set id(id: string): void
set id(id: string)
}

/**
Expand Down
63 changes: 32 additions & 31 deletions src/utils/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

import { NETLIFYDEVLOG, chalk, logAndThrowError, log, warn, APIError } from './command-helpers.js'
import { loadDotEnvFiles } from './dot-env.js'
import type { CachedConfig } from '../lib/build.js'
import type { NetlifySite } from '../commands/types.js'
import type { DevConfig } from '../commands/dev/types.js'
import type { EnvironmentVariables, SiteInfo } from './types.js'

// Possible sources of environment variables. For the purpose of printing log messages only. Order does not matter.
Expand Down Expand Up @@ -41,8 +44,7 @@
const ERROR_CALL_TO_ACTION =
"Double-check your login status with 'netlify status' or contact support with details of your error."

// @ts-expect-error TS(7031) FIXME: Binding element 'site' implicitly has an 'any' typ... Remove this comment to see the full error message
const validateSiteInfo = ({ site, siteInfo }) => {
const validateSiteInfo = ({ site, siteInfo }: { site: NetlifySite; siteInfo: SiteInfo }): void => {
if (isEmpty(siteInfo)) {
return logAndThrowError(
`Failed to retrieve project information for project ${chalk.yellow(site.id)}. ${ERROR_CALL_TO_ACTION}`,
Expand Down Expand Up @@ -73,9 +75,9 @@
}
}

// @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message
const getAddons = async ({ api, site }) => {
const getAddons = async ({ api, site }: { api: NetlifyAPI; site: NetlifySite }) => {
try {
// @ts-expect-error(serhalp) One of three types is incorrect here (is `site.id` optional?). Dig and fix.
const addons = await api.listServiceInstancesForSite({ siteId: site.id })
return addons
} catch (error_) {
Expand All @@ -87,13 +89,11 @@
}
}

// @ts-expect-error TS(7031) FIXME: Binding element 'addons' implicitly has an 'any' t... Remove this comment to see the full error message
const getAddonsInformation = ({ addons, siteInfo }) => {
type Addons = Awaited<ReturnType<NetlifyAPI['listServiceInstancesForSite']>>
const getAddonsInformation = ({ addons, siteInfo }: { addons: Addons; siteInfo: SiteInfo }) => {
const urls = Object.fromEntries(
// @ts-expect-error TS(7006) FIXME: Parameter 'addon' implicitly has an 'any' type.
addons.map((addon) => [addon.service_slug, `${siteInfo.ssl_url}${addon.service_path}`]),
)
// @ts-expect-error TS(7006) FIXME: Parameter 'addon' implicitly has an 'any' type.
const env = Object.assign({}, ...addons.map((addon) => addon.env))
return { urls, env }
}
Expand All @@ -113,17 +113,17 @@
// default 15 minutes for background functions
const BACKGROUND_FUNCTION_TIMEOUT = 900

/**
*
* @param {object} config
* @param {boolean} config.offline
* @param {*} config.api
* @param {*} config.site
* @param {*} config.siteInfo
* @returns
*/
// @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message
export const getSiteInformation = async ({ api, offline, site, siteInfo }) => {
export const getSiteInformation = async ({
api,
offline,
site,
siteInfo,
}: {
api: NetlifyAPI
offline: boolean
site: NetlifySite
siteInfo: SiteInfo
Copy link
Member

Choose a reason for hiding this comment

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

this introduced several type errors. you may need to fix SiteInfo itself?

}) => {
if (site.id && !offline) {
validateSiteInfo({ site, siteInfo })
const [accounts, addons] = await Promise.all([getAccounts({ api }), getAddons({ api, site })])
Expand All @@ -139,7 +139,7 @@
backgroundFunctions: supportsBackgroundFunctions(account),
},
timeouts: {
syncFunctions: siteInfo.functions_timeout ?? siteInfo.functions_config?.timeout ?? SYNCHRONOUS_FUNCTION_TIMEOUT,

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / typecheck

Property 'functions_config' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / typecheck

Property 'functions_timeout' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Unit (ubuntu-latest, 20.12.2)

Property 'functions_config' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Unit (ubuntu-latest, 20.12.2)

Property 'functions_timeout' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Unit (macOS-latest, 20.12.2)

Property 'functions_config' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Unit (macOS-latest, 20.12.2)

Property 'functions_timeout' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Unit (macOS-latest, 22.x)

Property 'functions_config' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Unit (macOS-latest, 22.x)

Property 'functions_timeout' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Unit (ubuntu-latest, 22.x)

Property 'functions_config' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Unit (ubuntu-latest, 22.x)

Property 'functions_timeout' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (ubuntu-latest, 20.12.2, 1/4)

Property 'functions_config' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (ubuntu-latest, 20.12.2, 1/4)

Property 'functions_timeout' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / E2E (macOS-latest, 22)

Property 'functions_config' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / E2E (macOS-latest, 22)

Property 'functions_timeout' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (ubuntu-latest, 22, 2/4)

Property 'functions_config' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (ubuntu-latest, 22, 2/4)

Property 'functions_timeout' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (macOS-latest, 20.12.2, 4/4)

Property 'functions_config' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (macOS-latest, 20.12.2, 4/4)

Property 'functions_timeout' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / E2E (ubuntu-latest, 22)

Property 'functions_config' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / E2E (ubuntu-latest, 22)

Property 'functions_timeout' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (macOS-latest, 22, 3/4)

Property 'functions_config' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (macOS-latest, 22, 3/4)

Property 'functions_timeout' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (ubuntu-latest, 22, 3/4)

Property 'functions_config' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (ubuntu-latest, 22, 3/4)

Property 'functions_timeout' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (macOS-latest, 22, 4/4)

Property 'functions_config' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (macOS-latest, 22, 4/4)

Property 'functions_timeout' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / E2E (ubuntu-latest, 20.12.2)

Property 'functions_config' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / E2E (ubuntu-latest, 20.12.2)

Property 'functions_timeout' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (ubuntu-latest, 20.12.2, 4/4)

Property 'functions_config' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (ubuntu-latest, 20.12.2, 4/4)

Property 'functions_timeout' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (ubuntu-latest, 22, 4/4)

Property 'functions_config' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (ubuntu-latest, 22, 4/4)

Property 'functions_timeout' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (ubuntu-latest, 20.12.2, 3/4)

Property 'functions_config' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (ubuntu-latest, 20.12.2, 3/4)

Property 'functions_timeout' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (ubuntu-latest, 22, 1/4)

Property 'functions_config' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (ubuntu-latest, 22, 1/4)

Property 'functions_timeout' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / E2E (macOS-latest, 20.12.2)

Property 'functions_config' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / E2E (macOS-latest, 20.12.2)

Property 'functions_timeout' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (macOS-latest, 20.12.2, 1/4)

Property 'functions_config' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (macOS-latest, 20.12.2, 1/4)

Property 'functions_timeout' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (macOS-latest, 22, 1/4)

Property 'functions_config' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (macOS-latest, 22, 1/4)

Property 'functions_timeout' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (macOS-latest, 22, 2/4)

Property 'functions_config' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (macOS-latest, 22, 2/4)

Property 'functions_timeout' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (macOS-latest, 20.12.2, 2/4)

Property 'functions_config' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (macOS-latest, 20.12.2, 2/4)

Property 'functions_timeout' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (ubuntu-latest, 20.12.2, 2/4)

Property 'functions_config' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (ubuntu-latest, 20.12.2, 2/4)

Property 'functions_timeout' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (macOS-latest, 20.12.2, 3/4)

Property 'functions_config' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (macOS-latest, 20.12.2, 3/4)

Property 'functions_timeout' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (windows-2025, 20.12.2, 3/4)

Property 'functions_config' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (windows-2025, 20.12.2, 3/4)

Property 'functions_timeout' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Unit (windows-2025, 20.12.2)

Property 'functions_config' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Unit (windows-2025, 20.12.2)

Property 'functions_timeout' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / E2E Windows tests (windows-2025, 22)

Property 'functions_config' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / E2E Windows tests (windows-2025, 22)

Property 'functions_timeout' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (windows-2025, 20.12.2, 1/4)

Property 'functions_config' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (windows-2025, 20.12.2, 1/4)

Property 'functions_timeout' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration test windows latest node23 specific

Property 'functions_config' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration test windows latest node23 specific

Property 'functions_timeout' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / E2E Windows tests (windows-2025, 20.12.2)

Property 'functions_config' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / E2E Windows tests (windows-2025, 20.12.2)

Property 'functions_timeout' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (windows-2025, 20.12.2, 2/4)

Property 'functions_config' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (windows-2025, 20.12.2, 2/4)

Property 'functions_timeout' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (windows-2025, 20.12.2, 4/4)

Property 'functions_config' does not exist on type 'SiteInfo'.

Check failure on line 142 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (windows-2025, 20.12.2, 4/4)

Property 'functions_timeout' does not exist on type 'SiteInfo'.
backgroundFunctions: BACKGROUND_FUNCTION_TIMEOUT,
},
}
Expand All @@ -157,21 +157,22 @@
}
}

// @ts-expect-error TS(7006) FIXME: Parameter 'source' implicitly has an 'any' type.
const getEnvSourceName = (source) => {
// @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
const { name = source, printFn = chalk.green } = ENV_VAR_SOURCES[source] || {}
const getEnvSourceName = (source: string) => {
const { name = source, printFn = chalk.green } = ENV_VAR_SOURCES[source] ?? {}

Check failure on line 161 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / typecheck

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ account: { name: string; printFn: ChalkInstance; }; addons: { name: string; printFn: ChalkInstance; }; configFile: { name: string; printFn: ChalkInstance; }; general: { ...; }; process: { ...; }; ui: { ...; }; }'.

Check failure on line 161 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Unit (ubuntu-latest, 20.12.2)

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ account: { name: string; printFn: ChalkInstance; }; addons: { name: string; printFn: ChalkInstance; }; configFile: { name: string; printFn: ChalkInstance; }; general: { ...; }; process: { ...; }; ui: { ...; }; }'.

Check failure on line 161 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Unit (macOS-latest, 20.12.2)

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ account: { name: string; printFn: ChalkInstance; }; addons: { name: string; printFn: ChalkInstance; }; configFile: { name: string; printFn: ChalkInstance; }; general: { ...; }; process: { ...; }; ui: { ...; }; }'.

Check failure on line 161 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Unit (macOS-latest, 22.x)

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ account: { name: string; printFn: ChalkInstance; }; addons: { name: string; printFn: ChalkInstance; }; configFile: { name: string; printFn: ChalkInstance; }; general: { ...; }; process: { ...; }; ui: { ...; }; }'.

Check failure on line 161 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Unit (ubuntu-latest, 22.x)

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ account: { name: string; printFn: ChalkInstance; }; addons: { name: string; printFn: ChalkInstance; }; configFile: { name: string; printFn: ChalkInstance; }; general: { ...; }; process: { ...; }; ui: { ...; }; }'.

Check failure on line 161 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (ubuntu-latest, 20.12.2, 1/4)

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ account: { name: string; printFn: ChalkInstance; }; addons: { name: string; printFn: ChalkInstance; }; configFile: { name: string; printFn: ChalkInstance; }; general: { ...; }; process: { ...; }; ui: { ...; }; }'.

Check failure on line 161 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / E2E (macOS-latest, 22)

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ account: { name: string; printFn: ChalkInstance; }; addons: { name: string; printFn: ChalkInstance; }; configFile: { name: string; printFn: ChalkInstance; }; general: { ...; }; process: { ...; }; ui: { ...; }; }'.

Check failure on line 161 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (ubuntu-latest, 22, 2/4)

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ account: { name: string; printFn: ChalkInstance; }; addons: { name: string; printFn: ChalkInstance; }; configFile: { name: string; printFn: ChalkInstance; }; general: { ...; }; process: { ...; }; ui: { ...; }; }'.

Check failure on line 161 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (macOS-latest, 20.12.2, 4/4)

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ account: { name: string; printFn: ChalkInstance; }; addons: { name: string; printFn: ChalkInstance; }; configFile: { name: string; printFn: ChalkInstance; }; general: { ...; }; process: { ...; }; ui: { ...; }; }'.

Check failure on line 161 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / E2E (ubuntu-latest, 22)

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ account: { name: string; printFn: ChalkInstance; }; addons: { name: string; printFn: ChalkInstance; }; configFile: { name: string; printFn: ChalkInstance; }; general: { ...; }; process: { ...; }; ui: { ...; }; }'.

Check failure on line 161 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (macOS-latest, 22, 3/4)

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ account: { name: string; printFn: ChalkInstance; }; addons: { name: string; printFn: ChalkInstance; }; configFile: { name: string; printFn: ChalkInstance; }; general: { ...; }; process: { ...; }; ui: { ...; }; }'.

Check failure on line 161 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (ubuntu-latest, 22, 3/4)

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ account: { name: string; printFn: ChalkInstance; }; addons: { name: string; printFn: ChalkInstance; }; configFile: { name: string; printFn: ChalkInstance; }; general: { ...; }; process: { ...; }; ui: { ...; }; }'.

Check failure on line 161 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (macOS-latest, 22, 4/4)

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ account: { name: string; printFn: ChalkInstance; }; addons: { name: string; printFn: ChalkInstance; }; configFile: { name: string; printFn: ChalkInstance; }; general: { ...; }; process: { ...; }; ui: { ...; }; }'.

Check failure on line 161 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / E2E (ubuntu-latest, 20.12.2)

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ account: { name: string; printFn: ChalkInstance; }; addons: { name: string; printFn: ChalkInstance; }; configFile: { name: string; printFn: ChalkInstance; }; general: { ...; }; process: { ...; }; ui: { ...; }; }'.

Check failure on line 161 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (ubuntu-latest, 20.12.2, 4/4)

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ account: { name: string; printFn: ChalkInstance; }; addons: { name: string; printFn: ChalkInstance; }; configFile: { name: string; printFn: ChalkInstance; }; general: { ...; }; process: { ...; }; ui: { ...; }; }'.

Check failure on line 161 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (ubuntu-latest, 22, 4/4)

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ account: { name: string; printFn: ChalkInstance; }; addons: { name: string; printFn: ChalkInstance; }; configFile: { name: string; printFn: ChalkInstance; }; general: { ...; }; process: { ...; }; ui: { ...; }; }'.

Check failure on line 161 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (ubuntu-latest, 20.12.2, 3/4)

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ account: { name: string; printFn: ChalkInstance; }; addons: { name: string; printFn: ChalkInstance; }; configFile: { name: string; printFn: ChalkInstance; }; general: { ...; }; process: { ...; }; ui: { ...; }; }'.

Check failure on line 161 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (ubuntu-latest, 22, 1/4)

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ account: { name: string; printFn: ChalkInstance; }; addons: { name: string; printFn: ChalkInstance; }; configFile: { name: string; printFn: ChalkInstance; }; general: { ...; }; process: { ...; }; ui: { ...; }; }'.

Check failure on line 161 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / E2E (macOS-latest, 20.12.2)

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ account: { name: string; printFn: ChalkInstance; }; addons: { name: string; printFn: ChalkInstance; }; configFile: { name: string; printFn: ChalkInstance; }; general: { ...; }; process: { ...; }; ui: { ...; }; }'.

Check failure on line 161 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (macOS-latest, 20.12.2, 1/4)

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ account: { name: string; printFn: ChalkInstance; }; addons: { name: string; printFn: ChalkInstance; }; configFile: { name: string; printFn: ChalkInstance; }; general: { ...; }; process: { ...; }; ui: { ...; }; }'.

Check failure on line 161 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (macOS-latest, 22, 1/4)

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ account: { name: string; printFn: ChalkInstance; }; addons: { name: string; printFn: ChalkInstance; }; configFile: { name: string; printFn: ChalkInstance; }; general: { ...; }; process: { ...; }; ui: { ...; }; }'.

Check failure on line 161 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (macOS-latest, 22, 2/4)

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ account: { name: string; printFn: ChalkInstance; }; addons: { name: string; printFn: ChalkInstance; }; configFile: { name: string; printFn: ChalkInstance; }; general: { ...; }; process: { ...; }; ui: { ...; }; }'.

Check failure on line 161 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (macOS-latest, 20.12.2, 2/4)

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ account: { name: string; printFn: ChalkInstance; }; addons: { name: string; printFn: ChalkInstance; }; configFile: { name: string; printFn: ChalkInstance; }; general: { ...; }; process: { ...; }; ui: { ...; }; }'.

Check failure on line 161 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (ubuntu-latest, 20.12.2, 2/4)

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ account: { name: string; printFn: ChalkInstance; }; addons: { name: string; printFn: ChalkInstance; }; configFile: { name: string; printFn: ChalkInstance; }; general: { ...; }; process: { ...; }; ui: { ...; }; }'.

Check failure on line 161 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (macOS-latest, 20.12.2, 3/4)

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ account: { name: string; printFn: ChalkInstance; }; addons: { name: string; printFn: ChalkInstance; }; configFile: { name: string; printFn: ChalkInstance; }; general: { ...; }; process: { ...; }; ui: { ...; }; }'.

Check failure on line 161 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (windows-2025, 20.12.2, 3/4)

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ account: { name: string; printFn: ChalkInstance; }; addons: { name: string; printFn: ChalkInstance; }; configFile: { name: string; printFn: ChalkInstance; }; general: { ...; }; process: { ...; }; ui: { ...; }; }'.

Check failure on line 161 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Unit (windows-2025, 20.12.2)

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ account: { name: string; printFn: ChalkInstance; }; addons: { name: string; printFn: ChalkInstance; }; configFile: { name: string; printFn: ChalkInstance; }; general: { ...; }; process: { ...; }; ui: { ...; }; }'.

Check failure on line 161 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / E2E Windows tests (windows-2025, 22)

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ account: { name: string; printFn: ChalkInstance; }; addons: { name: string; printFn: ChalkInstance; }; configFile: { name: string; printFn: ChalkInstance; }; general: { ...; }; process: { ...; }; ui: { ...; }; }'.

Check failure on line 161 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (windows-2025, 20.12.2, 1/4)

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ account: { name: string; printFn: ChalkInstance; }; addons: { name: string; printFn: ChalkInstance; }; configFile: { name: string; printFn: ChalkInstance; }; general: { ...; }; process: { ...; }; ui: { ...; }; }'.

Check failure on line 161 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration test windows latest node23 specific

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ account: { name: string; printFn: ChalkInstance; }; addons: { name: string; printFn: ChalkInstance; }; configFile: { name: string; printFn: ChalkInstance; }; general: { ...; }; process: { ...; }; ui: { ...; }; }'.

Check failure on line 161 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / E2E Windows tests (windows-2025, 20.12.2)

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ account: { name: string; printFn: ChalkInstance; }; addons: { name: string; printFn: ChalkInstance; }; configFile: { name: string; printFn: ChalkInstance; }; general: { ...; }; process: { ...; }; ui: { ...; }; }'.

Check failure on line 161 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (windows-2025, 20.12.2, 2/4)

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ account: { name: string; printFn: ChalkInstance; }; addons: { name: string; printFn: ChalkInstance; }; configFile: { name: string; printFn: ChalkInstance; }; general: { ...; }; process: { ...; }; ui: { ...; }; }'.

Check failure on line 161 in src/utils/dev.ts

View workflow job for this annotation

GitHub Actions / Integration (windows-2025, 20.12.2, 4/4)

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ account: { name: string; printFn: ChalkInstance; }; addons: { name: string; printFn: ChalkInstance; }; configFile: { name: string; printFn: ChalkInstance; }; general: { ...; }; process: { ...; }; ui: { ...; }; }'.
Comment on lines +160 to +161
Copy link
Member

Choose a reason for hiding this comment

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

lots of type errors here. I think an enum or a union of literal strings is needed.


return printFn(name)
}

/**
* @param {{devConfig: any, env: Record<string, { sources: string[], value: string}>, site: any}} param0
*/
// @ts-expect-error TS(7031) FIXME: Binding element 'devConfig' implicitly has an 'any... Remove this comment to see the full error message
export const getDotEnvVariables = async ({ devConfig, env, site }): Promise<EnvironmentVariables> => {
export const getDotEnvVariables = async ({
devConfig,
env,
site,
}: {
devConfig: DevConfig
env: CachedConfig['env']
site: NetlifySite
}): Promise<Record<string, { sources: string[]; value: string }>> => {
const dotEnvFiles = await loadDotEnvFiles({ envFiles: devConfig.envFiles, projectDir: site.root })
// @ts-expect-error TS(2339) FIXME: Property 'env' does not exist on type '{ warning: ... Remove this comment to see the full error message
dotEnvFiles.forEach(({ env: fileEnv, file }) => {
const newSourceName = `${file} file`

Expand All @@ -183,6 +184,7 @@
}

env[key] = {
// @ts-expect-error(serhalp) Something isn't right with these types but it's a can of worms.
sources,
value: fileEnv[key],
}
Expand Down Expand Up @@ -248,8 +250,7 @@
return acquiredPort
}

// @ts-expect-error TS(7006) FIXME: Parameter 'fn' implicitly has an 'any' type.
export const processOnExit = (fn) => {
export const processOnExit = (fn: (...args: unknown[]) => void) => {
const signals = ['SIGINT', 'SIGTERM', 'SIGQUIT', 'SIGHUP', 'exit']
signals.forEach((signal) => {
process.on(signal, fn)
Expand Down
50 changes: 32 additions & 18 deletions src/utils/dot-env.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,58 @@
import { readFile } from 'fs/promises'
import path from 'path'

import dotenv from 'dotenv'
import dotenv, { type DotenvParseOutput } from 'dotenv'

import { isFileAsync } from '../lib/fs.js'

import { warn } from './command-helpers.js'

// @ts-expect-error TS(7031) FIXME: Binding element 'envFiles' implicitly has an 'any'... Remove this comment to see the full error message
export const loadDotEnvFiles = async function ({ envFiles, projectDir }) {
const response = await tryLoadDotEnvFiles({ projectDir, dotenvFiles: envFiles })
interface LoadedDotEnvFile {
file: string
env: DotenvParseOutput
}

export const loadDotEnvFiles = async function ({
envFiles,
projectDir,
}: {
envFiles?: string[]
projectDir?: string
}): Promise<LoadedDotEnvFile[]> {
const loadedDotEnvFiles = await tryLoadDotEnvFiles({ projectDir, dotenvFiles: envFiles })

// @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'.
const filesWithWarning = response.filter((el) => el.warning)
filesWithWarning.forEach((el) => {
// @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'.
warn(el.warning)
})
loadedDotEnvFiles
.filter((el): el is { warning: string } => 'warning' in el)
.forEach((el) => {
warn(el.warning)
})

// @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'.
return response.filter((el) => el.file && el.env)
return loadedDotEnvFiles.filter((el): el is LoadedDotEnvFile => 'file' in el && 'env' in el)
Comment on lines -22 to +30
Copy link
Member

Choose a reason for hiding this comment

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

Let's avoid behavioural changes here, so also check for truthiness

}

// in the user configuration, the order is highest to lowest
const defaultEnvFiles = ['.env.development.local', '.env.local', '.env.development', '.env']

// @ts-expect-error TS(7031) FIXME: Binding element 'projectDir' implicitly has an 'an... Remove this comment to see the full error message
export const tryLoadDotEnvFiles = async ({ dotenvFiles = defaultEnvFiles, projectDir }) => {
export const tryLoadDotEnvFiles = async ({
dotenvFiles = defaultEnvFiles,
projectDir,
}: {
dotenvFiles?: string[]
projectDir?: string
}): Promise<Array<LoadedDotEnvFile | { warning: string }>> => {

Check failure on line 42 in src/utils/dot-env.ts

View workflow job for this annotation

GitHub Actions / Lint

Array type using 'Array<T>' is forbidden. Use 'T[]' instead
const results = await Promise.all(
dotenvFiles.map(async (file) => {
const filepath = path.resolve(projectDir, file)
const filepath = path.resolve(projectDir ?? '', file)
try {
const isFile = await isFileAsync(filepath)
if (!isFile) {
return
}
} catch (error) {
return {
// @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
warning: `Failed reading env variables from file: ${filepath}: ${error.message}`,
warning: `Failed reading env variables from file: ${filepath}: ${
error instanceof Error ? error.message : error?.toString()
}`,
}
}
const content = await readFile(filepath, 'utf-8')
Expand All @@ -48,5 +62,5 @@
)

// we return in order of lowest to highest priority
return results.filter(Boolean).reverse()
return results.filter((result): result is LoadedDotEnvFile => result != null).reverse()
}
4 changes: 2 additions & 2 deletions src/utils/open-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ const unableToOpenBrowserMessage = function ({ message, url }: BrowserUnableMess
log('---------------------------')
}

type OpenBrowsrProps = {
type OpenBrowserProps = {
silentBrowserNoneError?: boolean
url: string
}

const openBrowser = async function ({ silentBrowserNoneError, url }: OpenBrowsrProps) {
const openBrowser = async function ({ silentBrowserNoneError, url }: OpenBrowserProps) {
if (isDockerContainer()) {
unableToOpenBrowserMessage({ url, message: 'Running inside a docker container' })
return
Expand Down
2 changes: 1 addition & 1 deletion src/utils/proxy-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const startProxyServer = async ({
state,
}: {
accountId: string | undefined
addonsUrls: $TSFixMe
addonsUrls: Record<string, string>
api?: NetlifyOptions['api']
blobsContext?: BlobsContextWithEdgeAccess
command: BaseCommand
Expand Down
Loading