@@ -8,6 +8,9 @@ import { supportsBackgroundFunctions } from '../lib/account.js'
88
99import { NETLIFYDEVLOG , chalk , logAndThrowError , log , warn , APIError } from './command-helpers.js'
1010import { loadDotEnvFiles } from './dot-env.js'
11+ import type { CachedConfig } from '../lib/build.js'
12+ import type { NetlifySite } from '../commands/types.js'
13+ import type { DevConfig } from '../commands/dev/types.js'
1114import type { EnvironmentVariables , SiteInfo } from './types.js'
1215
1316// Possible sources of environment variables. For the purpose of printing log messages only. Order does not matter.
@@ -41,8 +44,7 @@ const ENV_VAR_SOURCES = {
4144const ERROR_CALL_TO_ACTION =
4245 "Double-check your login status with 'netlify status' or contact support with details of your error."
4346
44- // @ts -expect-error TS(7031) FIXME: Binding element 'site' implicitly has an 'any' typ... Remove this comment to see the full error message
45- const validateSiteInfo = ( { site, siteInfo } ) => {
47+ const validateSiteInfo = ( { site, siteInfo } : { site : NetlifySite ; siteInfo : SiteInfo } ) : void => {
4648 if ( isEmpty ( siteInfo ) ) {
4749 return logAndThrowError (
4850 `Failed to retrieve project information for project ${ chalk . yellow ( site . id ) } . ${ ERROR_CALL_TO_ACTION } ` ,
@@ -73,9 +75,9 @@ const getAccounts = async ({ api }: { api: NetlifyAPI }) => {
7375 }
7476}
7577
76- // @ts -expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message
77- const getAddons = async ( { api, site } ) => {
78+ const getAddons = async ( { api, site } : { api : NetlifyAPI ; site : NetlifySite } ) => {
7879 try {
80+ // @ts -expect-error(serhalp) One of three types is incorrect here (is `site.id` optional?). Dig and fix.
7981 const addons = await api . listServiceInstancesForSite ( { siteId : site . id } )
8082 return addons
8183 } catch ( error_ ) {
@@ -87,13 +89,11 @@ const getAddons = async ({ api, site }) => {
8789 }
8890}
8991
90- // @ts -expect-error TS(7031) FIXME: Binding element 'addons' implicitly has an 'any' t... Remove this comment to see the full error message
91- const getAddonsInformation = ( { addons, siteInfo } ) => {
92+ type Addons = Awaited < ReturnType < NetlifyAPI [ 'listServiceInstancesForSite' ] > >
93+ const getAddonsInformation = ( { addons, siteInfo } : { addons : Addons ; siteInfo : SiteInfo } ) => {
9294 const urls = Object . fromEntries (
93- // @ts -expect-error TS(7006) FIXME: Parameter 'addon' implicitly has an 'any' type.
9495 addons . map ( ( addon ) => [ addon . service_slug , `${ siteInfo . ssl_url } ${ addon . service_path } ` ] ) ,
9596 )
96- // @ts -expect-error TS(7006) FIXME: Parameter 'addon' implicitly has an 'any' type.
9797 const env = Object . assign ( { } , ...addons . map ( ( addon ) => addon . env ) )
9898 return { urls, env }
9999}
@@ -113,17 +113,17 @@ const SYNCHRONOUS_FUNCTION_TIMEOUT = 30
113113// default 15 minutes for background functions
114114const BACKGROUND_FUNCTION_TIMEOUT = 900
115115
116- /**
117- *
118- * @param { object } config
119- * @param { boolean } config.offline
120- * @param { * } config.api
121- * @param { * } config.site
122- * @param { * } config.siteInfo
123- * @returns
124- */
125- // @ts -expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message
126- export const getSiteInformation = async ( { api , offline , site , siteInfo } ) => {
116+ export const getSiteInformation = async ( {
117+ api ,
118+ offline ,
119+ site ,
120+ siteInfo ,
121+ } : {
122+ api : NetlifyAPI
123+ offline : boolean
124+ site : NetlifySite
125+ siteInfo : SiteInfo
126+ } ) => {
127127 if ( site . id && ! offline ) {
128128 validateSiteInfo ( { site, siteInfo } )
129129 const [ accounts , addons ] = await Promise . all ( [ getAccounts ( { api } ) , getAddons ( { api, site } ) ] )
@@ -157,21 +157,22 @@ export const getSiteInformation = async ({ api, offline, site, siteInfo }) => {
157157 }
158158}
159159
160- // @ts -expect-error TS(7006) FIXME: Parameter 'source' implicitly has an 'any' type.
161- const getEnvSourceName = ( source ) => {
162- // @ts -expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
163- const { name = source , printFn = chalk . green } = ENV_VAR_SOURCES [ source ] || { }
160+ const getEnvSourceName = ( source : string ) => {
161+ const { name = source , printFn = chalk . green } = ENV_VAR_SOURCES [ source ] ?? { }
164162
165163 return printFn ( name )
166164}
167165
168- /**
169- * @param {{devConfig: any, env: Record<string, { sources: string[], value: string}>, site: any} } param0
170- */
171- // @ts -expect-error TS(7031) FIXME: Binding element 'devConfig' implicitly has an 'any... Remove this comment to see the full error message
172- export const getDotEnvVariables = async ( { devConfig, env, site } ) : Promise < EnvironmentVariables > => {
166+ export const getDotEnvVariables = async ( {
167+ devConfig,
168+ env,
169+ site,
170+ } : {
171+ devConfig : DevConfig
172+ env : CachedConfig [ 'env' ]
173+ site : NetlifySite
174+ } ) : Promise < Record < string , { sources : string [ ] ; value : string } > > => {
173175 const dotEnvFiles = await loadDotEnvFiles ( { envFiles : devConfig . envFiles , projectDir : site . root } )
174- // @ts -expect-error TS(2339) FIXME: Property 'env' does not exist on type '{ warning: ... Remove this comment to see the full error message
175176 dotEnvFiles . forEach ( ( { env : fileEnv , file } ) => {
176177 const newSourceName = `${ file } file`
177178
@@ -183,6 +184,7 @@ export const getDotEnvVariables = async ({ devConfig, env, site }): Promise<Envi
183184 }
184185
185186 env [ key ] = {
187+ // @ts -expect-error(serhalp) Something isn't right with these types but it's a can of worms.
186188 sources,
187189 value : fileEnv [ key ] ,
188190 }
@@ -248,8 +250,7 @@ export const acquirePort = async ({
248250 return acquiredPort
249251}
250252
251- // @ts -expect-error TS(7006) FIXME: Parameter 'fn' implicitly has an 'any' type.
252- export const processOnExit = ( fn ) => {
253+ export const processOnExit = ( fn : ( ...args : unknown [ ] ) => void ) => {
253254 const signals = [ 'SIGINT' , 'SIGTERM' , 'SIGQUIT' , 'SIGHUP' , 'exit' ]
254255 signals . forEach ( ( signal ) => {
255256 process . on ( signal , fn )
0 commit comments