@@ -8,6 +8,9 @@ import { supportsBackgroundFunctions } from '../lib/account.js'
8
8
9
9
import { NETLIFYDEVLOG , chalk , logAndThrowError , log , warn , APIError } from './command-helpers.js'
10
10
import { 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'
11
14
import type { EnvironmentVariables , SiteInfo } from './types.js'
12
15
13
16
// 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 = {
41
44
const ERROR_CALL_TO_ACTION =
42
45
"Double-check your login status with 'netlify status' or contact support with details of your error."
43
46
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 => {
46
48
if ( isEmpty ( siteInfo ) ) {
47
49
return logAndThrowError (
48
50
`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 }) => {
73
75
}
74
76
}
75
77
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 } ) => {
78
79
try {
80
+ // @ts -expect-error(serhalp) One of three types is incorrect here (is `site.id` optional?). Dig and fix.
79
81
const addons = await api . listServiceInstancesForSite ( { siteId : site . id } )
80
82
return addons
81
83
} catch ( error_ ) {
@@ -87,13 +89,11 @@ const getAddons = async ({ api, site }) => {
87
89
}
88
90
}
89
91
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 } ) => {
92
94
const urls = Object . fromEntries (
93
- // @ts -expect-error TS(7006) FIXME: Parameter 'addon' implicitly has an 'any' type.
94
95
addons . map ( ( addon ) => [ addon . service_slug , `${ siteInfo . ssl_url } ${ addon . service_path } ` ] ) ,
95
96
)
96
- // @ts -expect-error TS(7006) FIXME: Parameter 'addon' implicitly has an 'any' type.
97
97
const env = Object . assign ( { } , ...addons . map ( ( addon ) => addon . env ) )
98
98
return { urls, env }
99
99
}
@@ -113,17 +113,17 @@ const SYNCHRONOUS_FUNCTION_TIMEOUT = 30
113
113
// default 15 minutes for background functions
114
114
const BACKGROUND_FUNCTION_TIMEOUT = 900
115
115
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
+ } ) => {
127
127
if ( site . id && ! offline ) {
128
128
validateSiteInfo ( { site, siteInfo } )
129
129
const [ accounts , addons ] = await Promise . all ( [ getAccounts ( { api } ) , getAddons ( { api, site } ) ] )
@@ -157,21 +157,22 @@ export const getSiteInformation = async ({ api, offline, site, siteInfo }) => {
157
157
}
158
158
}
159
159
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 ] ?? { }
164
162
165
163
return printFn ( name )
166
164
}
167
165
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 } > > => {
173
175
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
175
176
dotEnvFiles . forEach ( ( { env : fileEnv , file } ) => {
176
177
const newSourceName = `${ file } file`
177
178
@@ -183,6 +184,7 @@ export const getDotEnvVariables = async ({ devConfig, env, site }): Promise<Envi
183
184
}
184
185
185
186
env [ key ] = {
187
+ // @ts -expect-error(serhalp) Something isn't right with these types but it's a can of worms.
186
188
sources,
187
189
value : fileEnv [ key ] ,
188
190
}
@@ -248,8 +250,7 @@ export const acquirePort = async ({
248
250
return acquiredPort
249
251
}
250
252
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 ) => {
253
254
const signals = [ 'SIGINT' , 'SIGTERM' , 'SIGQUIT' , 'SIGHUP' , 'exit' ]
254
255
signals . forEach ( ( signal ) => {
255
256
process . on ( signal , fn )
0 commit comments