@@ -196,22 +196,18 @@ async function loadMetroConfigFromDisk(
196
196
const rootPath = dirname ( filepath ) ;
197
197
198
198
const defaults = await getDefaultConfig ( rootPath ) ;
199
- // $FlowFixMe[incompatible-variance]
200
- // $FlowFixMe[incompatible-call]
199
+
201
200
const defaultConfig : ConfigT = mergeConfig ( defaults , defaultConfigOverrides ) ;
202
201
203
202
if ( typeof configModule === 'function' ) {
204
203
// Get a default configuration based on what we know, which we in turn can pass
205
204
// to the function.
206
205
207
206
const resultedConfig = await configModule ( defaultConfig ) ;
208
- // $FlowFixMe[incompatible-call]
209
- // $FlowFixMe[incompatible-variance]
207
+
210
208
return mergeConfig ( defaultConfig , resultedConfig ) ;
211
209
}
212
210
213
- // $FlowFixMe[incompatible-variance]
214
- // $FlowFixMe[incompatible-call]
215
211
return mergeConfig ( defaultConfig , configModule ) ;
216
212
}
217
213
@@ -220,17 +216,21 @@ function overrideConfigWithArguments(
220
216
argv : YargArguments ,
221
217
) : ConfigT {
222
218
// We override some config arguments here with the argv
223
-
224
- const output : InputConfigT = {
219
+ const output : {
220
+ // Spread to remove invariance so that `output` is mutable.
221
+ ...Partial < ConfigT > ,
222
+ resolver : { ...Partial < ConfigT [ 'resolver' ] > } ,
223
+ serializer : { ...Partial < ConfigT [ 'serializer' ] > } ,
224
+ server : { ...Partial < ConfigT [ 'server' ] > } ,
225
+ transformer : { ...Partial < ConfigT [ 'transformer' ] > } ,
226
+ } = {
225
227
resolver : { } ,
226
228
serializer : { } ,
227
229
server : { } ,
228
230
transformer : { } ,
229
231
} ;
230
232
231
233
if ( argv . port != null ) {
232
- // $FlowFixMe[incompatible-use]
233
- // $FlowFixMe[cannot-write]
234
234
output . server . port = Number ( argv . port ) ;
235
235
}
236
236
@@ -243,20 +243,14 @@ function overrideConfigWithArguments(
243
243
}
244
244
245
245
if ( argv . assetExts != null ) {
246
- // $FlowFixMe[incompatible-use]
247
- // $FlowFixMe[cannot-write]
248
246
output . resolver . assetExts = argv . assetExts ;
249
247
}
250
248
251
249
if ( argv . sourceExts != null ) {
252
- // $FlowFixMe[incompatible-use]
253
- // $FlowFixMe[cannot-write]
254
250
output . resolver . sourceExts = argv . sourceExts ;
255
251
}
256
252
257
253
if ( argv . platforms != null ) {
258
- // $FlowFixMe[incompatible-use]
259
- // $FlowFixMe[cannot-write]
260
254
output . resolver . platforms = argv . platforms ;
261
255
}
262
256
@@ -265,8 +259,6 @@ function overrideConfigWithArguments(
265
259
}
266
260
267
261
if ( argv . transformer != null ) {
268
- // $FlowFixMe[incompatible-use]
269
- // $FlowFixMe[cannot-write]
270
262
output . transformer . babelTransformerPath = argv . transformer ;
271
263
}
272
264
@@ -283,8 +275,6 @@ function overrideConfigWithArguments(
283
275
// TODO: Ask if this is the way to go
284
276
}
285
277
286
- // $FlowFixMe[incompatible-variance]
287
- // $FlowFixMe[incompatible-call]
288
278
return mergeConfig ( config , output ) ;
289
279
}
290
280
@@ -319,19 +309,11 @@ async function loadConfig(
319
309
// Override the configuration with cli parameters
320
310
const configWithArgs = overrideConfigWithArguments ( configuration , argv ) ;
321
311
322
- const overriddenConfig : { [ string ] : mixed } = { } ;
323
-
324
- overriddenConfig . watchFolders = [
325
- configWithArgs . projectRoot ,
326
- ...configWithArgs . watchFolders ,
327
- ] ;
328
-
329
312
// Set the watchfolders to include the projectRoot, as Metro assumes that is
330
313
// the case
331
- // $FlowFixMe[incompatible-variance]
332
- // $FlowFixMe[incompatible-indexer]
333
- // $FlowFixMe[incompatible-call]
334
- return mergeConfig ( configWithArgs , overriddenConfig ) ;
314
+ return mergeConfig ( configWithArgs , {
315
+ watchFolders : [ configWithArgs . projectRoot , ...configWithArgs . watchFolders ] ,
316
+ } ) ;
335
317
}
336
318
337
319
module . exports = {
0 commit comments