Skip to content

Commit

Permalink
Codemod $Shape to Partial, some final updates
Browse files Browse the repository at this point in the history
Summary:
We're deprecating the unsafe `$Shape` and moving to the safe `Partial`: https://fb.workplace.com/groups/flowlang/posts/1251655088773485

(Some of these are template files)

Reviewed By: SamChou19815

Differential Revision: D45173866

fbshipit-source-id: f435410e073cffba8e1da8a4e387141bcdf8b006
  • Loading branch information
gkz authored and facebook-github-bot committed May 3, 2023
1 parent 97d5544 commit e04c65d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
24 changes: 13 additions & 11 deletions packages/metro-config/src/configTypes.flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export type Middleware = (
((e: ?Error) => mixed),
) => mixed;

type PerfAnnotations = $Shape<{
type PerfAnnotations = Partial<{
string: {[key: string]: string},
int: {[key: string]: number},
double: {[key: string]: number},
Expand Down Expand Up @@ -204,21 +204,23 @@ type WatcherConfigT = {
},
};

export type InputConfigT = $Shape<{
export type InputConfigT = Partial<{
...MetalConfigT,
...$ReadOnly<{
cacheStores:
| $ReadOnlyArray<CacheStore<TransformResult<>>>
| (MetroCache => $ReadOnlyArray<CacheStore<TransformResult<>>>),
resolver: $Shape<ResolverConfigT>,
server: $Shape<ServerConfigT>,
serializer: $Shape<SerializerConfigT>,
symbolicator: $Shape<SymbolicatorConfigT>,
transformer: $Shape<TransformerConfigT>,
watcher: $Shape<{
...WatcherConfigT,
healthCheck?: $Shape<WatcherConfigT['healthCheck']>,
}>,
resolver: $ReadOnly<Partial<ResolverConfigT>>,
server: $ReadOnly<Partial<ServerConfigT>>,
serializer: $ReadOnly<Partial<SerializerConfigT>>,
symbolicator: $ReadOnly<Partial<SymbolicatorConfigT>>,
transformer: $ReadOnly<Partial<TransformerConfigT>>,
watcher: $ReadOnly<
Partial<{
...WatcherConfigT,
healthCheck?: $ReadOnly<Partial<WatcherConfigT['healthCheck']>>,
}>,
>,
}>,
}>;

Expand Down
8 changes: 7 additions & 1 deletion packages/metro-config/src/loadConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ async function resolveConfig(
return result;
}

function mergeConfig<T: InputConfigT>(
function mergeConfig<T: $ReadOnly<InputConfigT>>(
defaultConfig: T,
...configs: Array<InputConfigT>
): T {
Expand Down Expand Up @@ -225,11 +225,13 @@ function overrideConfigWithArguments(

if (argv.port != null) {
// $FlowFixMe[incompatible-use]
// $FlowFixMe[cannot-write]
output.server.port = Number(argv.port);
}

if (argv.runInspectorProxy != null) {
// $FlowFixMe[incompatible-use]
// $FlowFixMe[cannot-write]
output.server.runInspectorProxy = Boolean(argv.runInspectorProxy);
}

Expand All @@ -243,16 +245,19 @@ function overrideConfigWithArguments(

if (argv.assetExts != null) {
// $FlowFixMe[incompatible-use]
// $FlowFixMe[cannot-write]
output.resolver.assetExts = argv.assetExts;
}

if (argv.sourceExts != null) {
// $FlowFixMe[incompatible-use]
// $FlowFixMe[cannot-write]
output.resolver.sourceExts = argv.sourceExts;
}

if (argv.platforms != null) {
// $FlowFixMe[incompatible-use]
// $FlowFixMe[cannot-write]
output.resolver.platforms = argv.platforms;
}

Expand All @@ -262,6 +267,7 @@ function overrideConfigWithArguments(

if (argv.transformer != null) {
// $FlowFixMe[incompatible-use]
// $FlowFixMe[cannot-write]
output.transformer.babelTransformerPath = argv.transformer;
}

Expand Down

0 comments on commit e04c65d

Please sign in to comment.